Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 8e71a39

Browse files
committed
add -m flag
1 parent 59bb934 commit 8e71a39

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

engine/cli/command_line_parser.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ void CommandLineParser::SetupEngineCommands() {
342342
for (auto& engine : engine_service_.kSupportEngines) {
343343
std::string engine_name{engine};
344344
EngineInstall(install_cmd, engine_name, cml_data_.engine_version,
345-
cml_data_.engine_src, cml_data_.show_menu);
345+
cml_data_.engine_src);
346346
}
347347

348348
auto uninstall_cmd =
@@ -465,8 +465,7 @@ void CommandLineParser::SetupSystemCommands() {
465465

466466
void CommandLineParser::EngineInstall(CLI::App* parent,
467467
const std::string& engine_name,
468-
std::string& version, std::string& src,
469-
bool show_menu) {
468+
std::string& version, std::string& src) {
470469
auto install_engine_cmd = parent->add_subcommand(engine_name, "");
471470
install_engine_cmd->usage("Usage:\n" + commands::GetCortexBinary() +
472471
" engines install " + engine_name + " [options]");
@@ -478,16 +477,16 @@ void CommandLineParser::EngineInstall(CLI::App* parent,
478477
install_engine_cmd->add_option("-s, --source", src,
479478
"Install engine by local path");
480479

481-
install_engine_cmd->add_option("-m, --menu", show_menu,
482-
"Display menu for engine variant selection");
480+
install_engine_cmd->add_flag("-m, --menu", cml_data_.show_menu,
481+
"Display menu for engine variant selection");
483482

484-
install_engine_cmd->callback([this, engine_name, &version, &src, show_menu] {
483+
install_engine_cmd->callback([this, engine_name, &version, &src] {
485484
if (std::exchange(executed_, true))
486485
return;
487486
try {
488487
commands::EngineInstallCmd(
489488
download_service_, cml_data_.config.apiServerHost,
490-
std::stoi(cml_data_.config.apiServerPort), show_menu)
489+
std::stoi(cml_data_.config.apiServerPort), cml_data_.show_menu)
491490
.Exec(engine_name, version, src);
492491
} catch (const std::exception& e) {
493492
CTL_ERR(e.what());

engine/cli/command_line_parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CommandLineParser {
2323
void SetupSystemCommands();
2424

2525
void EngineInstall(CLI::App* parent, const std::string& engine_name,
26-
std::string& version, std::string& src, bool show_menu);
26+
std::string& version, std::string& src);
2727

2828
void EngineUninstall(CLI::App* parent, const std::string& engine_name);
2929

engine/cli/commands/engine_install_cmd.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ bool EngineInstallCmd::Exec(const std::string& engine,
3737
auto dp_res = std::async(std::launch::deferred, [&dp, &engine] {
3838
return dp.Handle(DownloadType::Engine);
3939
});
40-
CLI_LOG("Validating download items, please wait..")
4140

4241
auto versions_url = url_parser::Url{
4342
.protocol = "http",

engine/cli/commands/engine_list_cmd.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,23 @@ bool EngineListCmd::Exec(const std::string& host, int port) {
5757
}
5858
}
5959

60+
// TODO: namh support onnx and tensorrt
61+
auto default_engine_url = url_parser::Url{
62+
.protocol = "http",
63+
.host = host + ":" + std::to_string(port),
64+
.pathParams = {"v1", "engines", kLlamaEngine, "default"},
65+
};
66+
auto selected_variant_result =
67+
curl_utils::SimpleGetJson(default_engine_url.ToFullPath());
68+
69+
std::optional<std::pair<std::string, std::string>> variant_pair =
70+
std::nullopt;
71+
if (selected_variant_result.has_value()) {
72+
variant_pair = std::make_pair<std::string, std::string>(
73+
selected_variant_result.value()["variant"].asString(),
74+
selected_variant_result.value()["version"].asString());
75+
}
76+
6077
std::vector<EngineVariantResponse> output;
6178
for (const auto& [key, value] : engine_map) {
6279
output.insert(output.end(), value.begin(), value.end());
@@ -65,6 +82,12 @@ bool EngineListCmd::Exec(const std::string& host, int port) {
6582
int count = 0;
6683
for (auto const& v : output) {
6784
count += 1;
85+
if (variant_pair.has_value() && v.name == variant_pair->first &&
86+
v.version == variant_pair->second) {
87+
table.add_row(
88+
{std::to_string(count), v.engine, v.version, v.name, "Default"});
89+
continue;
90+
}
6891
table.add_row(
6992
{std::to_string(count), v.engine, v.version, v.name, "Installed"});
7093
}

0 commit comments

Comments
 (0)