|
1 | 1 | #include "command_line_parser.h" |
2 | 2 | #include <memory> |
3 | 3 | #include <optional> |
| 4 | +#include <string> |
4 | 5 | #include "commands/cortex_upd_cmd.h" |
5 | 6 | #include "commands/engine_get_cmd.h" |
6 | 7 | #include "commands/engine_install_cmd.h" |
7 | 8 | #include "commands/engine_list_cmd.h" |
| 9 | +#include "commands/engine_release_cmd.h" |
8 | 10 | #include "commands/engine_uninstall_cmd.h" |
9 | | -#include "commands/model_alias_cmd.h" |
10 | 11 | #include "commands/model_del_cmd.h" |
11 | 12 | #include "commands/model_get_cmd.h" |
12 | 13 | #include "commands/model_import_cmd.h" |
@@ -268,30 +269,6 @@ void CommandLineParser::SetupModelCommands() { |
268 | 269 | cml_data_.model_id); |
269 | 270 | }); |
270 | 271 |
|
271 | | - std::string model_alias; |
272 | | - auto model_alias_cmd = |
273 | | - models_cmd->add_subcommand("alias", "Add alias name for a modelID"); |
274 | | - model_alias_cmd->usage("Usage:\n" + commands::GetCortexBinary() + |
275 | | - " models alias --model_id [model_id] --alias [alias]"); |
276 | | - model_alias_cmd->group(kSubcommands); |
277 | | - model_alias_cmd->add_option( |
278 | | - "--model_id", cml_data_.model_id, |
279 | | - "Can be modelID or model alias to identify model"); |
280 | | - model_alias_cmd->add_option("--alias", cml_data_.model_alias, |
281 | | - "new alias to be set"); |
282 | | - model_alias_cmd->callback([this, model_alias_cmd]() { |
283 | | - if (std::exchange(executed_, true)) |
284 | | - return; |
285 | | - if (cml_data_.model_id.empty() || cml_data_.model_alias.empty()) { |
286 | | - CLI_LOG("[model_id] and [alias] are required\n"); |
287 | | - CLI_LOG(model_alias_cmd->help()); |
288 | | - return; |
289 | | - } |
290 | | - commands::ModelAliasCmd mdc; |
291 | | - mdc.Exec(cml_data_.config.apiServerHost, |
292 | | - std::stoi(cml_data_.config.apiServerPort), cml_data_.model_id, |
293 | | - cml_data_.model_alias); |
294 | | - }); |
295 | 272 | // Model update parameters comment |
296 | 273 | ModelUpdate(models_cmd); |
297 | 274 |
|
@@ -346,6 +323,21 @@ void CommandLineParser::SetupEngineCommands() { |
346 | 323 | std::stoi(cml_data_.config.apiServerPort)); |
347 | 324 | }); |
348 | 325 |
|
| 326 | + auto installv2_cmd = engines_cmd->add_subcommand("release", "Install engine"); |
| 327 | + installv2_cmd->group(kSubcommands); |
| 328 | + installv2_cmd->callback([this, installv2_cmd] { |
| 329 | + if (std::exchange(executed_, true)) |
| 330 | + return; |
| 331 | + if (installv2_cmd->get_subcommands().empty()) { |
| 332 | + CLI_LOG("[engine_name] is required\n"); |
| 333 | + CLI_LOG(installv2_cmd->help()); |
| 334 | + } |
| 335 | + }); |
| 336 | + for (auto& engine : engine_service_.kSupportEngines) { |
| 337 | + std::string engine_name{engine}; |
| 338 | + EngineInstallV2(installv2_cmd, engine_name); |
| 339 | + } |
| 340 | + |
349 | 341 | auto install_cmd = engines_cmd->add_subcommand("install", "Install engine"); |
350 | 342 | install_cmd->usage("Usage:\n" + commands::GetCortexBinary() + |
351 | 343 | " engines install [engine_name] [options]"); |
@@ -444,6 +436,25 @@ void CommandLineParser::SetupSystemCommands() { |
444 | 436 | }); |
445 | 437 | } |
446 | 438 |
|
| 439 | +void CommandLineParser::EngineInstallV2(CLI::App* parent, |
| 440 | + const std::string& engine_name) { |
| 441 | + auto install_engine_cmd = parent->add_subcommand(engine_name, ""); |
| 442 | + install_engine_cmd->usage("Usage:\n" + commands::GetCortexBinary() + |
| 443 | + " engines install " + engine_name + " [options]"); |
| 444 | + install_engine_cmd->group(kEngineGroup); |
| 445 | + install_engine_cmd->callback([this, engine_name] { |
| 446 | + if (std::exchange(executed_, true)) |
| 447 | + return; |
| 448 | + auto result = commands::EngineReleaseCmd().Exec( |
| 449 | + cml_data_.config.apiServerHost, |
| 450 | + std::stoi(cml_data_.config.apiServerPort), engine_name); |
| 451 | + |
| 452 | + if (result.has_error()) { |
| 453 | + CLI_LOG(result.error()); |
| 454 | + } |
| 455 | + }); |
| 456 | +} |
| 457 | + |
447 | 458 | void CommandLineParser::EngineInstall(CLI::App* parent, |
448 | 459 | const std::string& engine_name, |
449 | 460 | std::string& version, std::string& src) { |
|
0 commit comments