forked from janhq/cortex.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathengine_uninstall_cmd.cc
More file actions
35 lines (30 loc) · 1.01 KB
/
engine_uninstall_cmd.cc
File metadata and controls
35 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "engine_uninstall_cmd.h"
#include "server_start_cmd.h"
#include "utils/curl_utils.h"
#include "utils/logging_utils.h"
#include "utils/url_parser.h"
namespace commands {
void EngineUninstallCmd::Exec(const std::string& host, int port,
const std::string& engine) {
// Start server if server is not started yet
if (!commands::IsServerAlive(host, port)) {
CLI_LOG("Starting server ...");
commands::ServerStartCmd ssc;
if (!ssc.Exec(host, port)) {
return;
}
}
auto url =
url_parser::Url{/* .protocol = */ "http",
/* .host = */ host + ":" + std::to_string(port),
/* .pathParams = */ {"v1", "engines", engine, "install"},
/* .queries = */ {},
};
auto result = curl_utils::SimpleDeleteJson(url.ToFullPath());
if (result.has_error()) {
CTL_ERR(result.error());
return;
}
CLI_LOG("Engine " + engine + " uninstalled successfully!");
}
}; // namespace commands