Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ target_include_directories(cpp-workspace-core
add_executable(cpp-workspace-app src/main.cpp)
target_link_libraries(cpp-workspace-app PRIVATE cpp-workspace-core)

target_compile_options(cpp-workspace-app PRIVATE
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wpedantic -Wconversion -Wshadow>
$<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -Wpedantic -Wconversion -Wshadow>
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
)

target_compile_options(cpp-workspace-app PRIVATE
$<$<AND:$<CONFIG:Debug>,$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>>>:-g -O0>
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:MSVC>>:/Zi /Od /RTC1>
)

target_compile_options(cpp-workspace-app PRIVATE
$<$<AND:$<CONFIG:Release>,$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>>>:-O3>
$<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:MSVC>>:/O2>
)

find_package(fmt REQUIRED)
find_package(CURL REQUIRED)
find_package(nlohmann_json REQUIRED)
Expand Down
10 changes: 5 additions & 5 deletions src/interface/user_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void UserInterface::print_model_list_noninteractive(const std::vector<std::strin
void UserInterface::select_model(const std::vector<std::string>& models, std::string* model) {
int index{};

if (models.size() == 0) {
if ((int) models.size() == 0) {
this->print_error("There are no available models to select from.\n");
this->end_session(EXIT_FAILURE);
}
Expand Down Expand Up @@ -331,7 +331,7 @@ void UserInterface::select_model(const std::vector<std::string>& models, std::st

index = stoi(std::string(this->backend->get_input_buffer()));

if (index < 0 || index >= models.size()) {
if (index < 0 || index >= (int) models.size()) {
std::string message = std::format("Model index {} does not exist.\n", index);
this->print_error(message);
this->select_model(models, model);
Expand Down Expand Up @@ -361,15 +361,15 @@ void UserInterface::select_model_noninteractive(const std::vector<std::string>&
int index{};
int read_result{};

if (models.size() == 0) {
if ((int) models.size() == 0) {
UserInterface::print_error_noninteractive("There are no available models to select from.\n");
if (auto ui = instance.lock()) {
ui->end_session(EXIT_FAILURE);
}
}

while (read_result != 1 || index < 0 || index >= models.size()) {
if (index < 0 || index >= models.size()) {
while (read_result != 1 || index < 0 || index >= (int) models.size()) {
if (index < 0 || index >= (int) models.size()) {
UserInterface::print_error_noninteractive(std::format("Model index {} does not exist.\n", index));
}
UserInterface::print_message_noninteractive("Model index: ");
Expand Down
6 changes: 3 additions & 3 deletions src/utils/http_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class HttpException : public std::runtime_error {
/**
* The HTTP status code that triggered the exception.
*/
long status_code;
long _status_code;

public:
/**
Expand All @@ -49,7 +49,7 @@ class HttpException : public std::runtime_error {
* @endcode
*/
HttpException(long status_code, const std::string& url)
: std::runtime_error(std::format("HTTP {}: {}", status_code, url)), status_code(status_code) {
: std::runtime_error(std::format("HTTP {}: {}", status_code, url)), _status_code(status_code) {
}

/**
Expand All @@ -70,6 +70,6 @@ class HttpException : public std::runtime_error {
* @endcode
*/
long get_status_code() const {
return status_code;
return this->_status_code;
}
};
Loading