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

Commit 36de7e8

Browse files
committed
update
Signed-off-by: James <namnh0122@gmail.com>
1 parent 6f252de commit 36de7e8

24 files changed

+381
-397
lines changed

engine/commands/engine_get_cmd.cc

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,17 @@
66

77
namespace commands {
88

9-
void EngineGetCmd::Exec() const {
10-
CTL_INF("[EngineGetCmd] engine: " << engine_);
11-
12-
auto engine_service = EngineService();
13-
try {
14-
auto status = engine_service.GetEngineInfo(engine_);
15-
tabulate::Table table;
16-
table.add_row({"Name", "Supported Formats", "Version", "Status"});
17-
table.add_row(
18-
{status.product_name, status.format, status.version, status.status});
19-
std::cout << table << std::endl;
20-
} catch (const std::runtime_error& e) {
21-
std::cerr << "Engine " << engine_ << " is not supported!" << "\n";
22-
} catch (const std::exception& e) {
23-
std::cerr << "Failed to get engine info for " << engine_ << ": " << e.what()
24-
<< "\n";
9+
void EngineGetCmd::Exec(const std::string& engine_name) const {
10+
auto engine = engine_service_.GetEngineInfo(engine_name);
11+
if (engine == std::nullopt) {
12+
CLI_LOG("Engine " + engine_name + " is not supported!");
13+
return;
2514
}
15+
16+
tabulate::Table table;
17+
table.add_row({"Name", "Supported Formats", "Version", "Status"});
18+
table.add_row(
19+
{engine->product_name, engine->format, engine->version, engine->status});
20+
std::cout << table << std::endl;
2621
}
2722
}; // namespace commands

engine/commands/engine_get_cmd.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#pragma once
22

3-
#include <string>
3+
#include "services/engine_service.h"
44

55
namespace commands {
66
class EngineGetCmd {
77
public:
8-
EngineGetCmd(const std::string& engine) : engine_{engine} {};
8+
explicit EngineGetCmd() : engine_service_{EngineService()} {};
99

10-
void Exec() const;
10+
void Exec(const std::string& engineName) const;
1111

1212
private:
13-
std::string engine_;
13+
EngineService engine_service_;
1414
};
1515
} // namespace commands

engine/commands/engine_init_cmd.cc

Lines changed: 0 additions & 220 deletions
This file was deleted.

engine/commands/engine_init_cmd.h

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "engine_install_cmd.h"
2+
// clang-format off
3+
#include "utils/cortexso_parser.h"
4+
#include "utils/archive_utils.h"
5+
// clang-format on
6+
#include "utils/cuda_toolkit_utils.h"
7+
#include "utils/engine_matcher_utils.h"
8+
#include "utils/logging_utils.h"
9+
10+
namespace commands {
11+
12+
void EngineInstallCmd::Exec(const std::string& engine,
13+
const std::string& version) {
14+
engine_service_.InstallEngine(engine, version);
15+
CLI_LOG("Engine " << engine << " installed successfully!");
16+
}
17+
}; // namespace commands
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#include <string>
4+
#include "services/engine_service.h"
5+
6+
namespace commands {
7+
8+
class EngineInstallCmd {
9+
public:
10+
explicit EngineInstallCmd() : engine_service_{EngineService()} {};
11+
12+
void Exec(const std::string& engine, const std::string& version = "latest");
13+
14+
private:
15+
EngineService engine_service_;
16+
};
17+
} // namespace commands

engine/commands/engine_uninstall_cmd.cc

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,8 @@
44

55
namespace commands {
66

7-
EngineUninstallCmd::EngineUninstallCmd(std::string engine)
8-
: engine_{std::move(engine)} {}
9-
10-
void EngineUninstallCmd::Exec() const {
11-
CTL_INF("Uninstall engine " + engine_);
12-
auto engine_service = EngineService();
13-
14-
try {
15-
engine_service.UninstallEngine(engine_);
16-
CLI_LOG("Engine " << engine_ << " uninstalled successfully!")
17-
} catch (const std::exception& e) {
18-
CLI_LOG("Failed to uninstall engine " << engine_ << ": " << e.what());
19-
}
7+
void EngineUninstallCmd::Exec(const std::string& engine) {
8+
engine_service_.UninstallEngine(engine);
9+
CLI_LOG("Engine " << engine << " uninstalled successfully!");
2010
}
2111
}; // namespace commands
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#pragma once
22

33
#include <string>
4+
#include "services/engine_service.h"
45

56
namespace commands {
67
class EngineUninstallCmd {
78
public:
8-
EngineUninstallCmd(std::string engine);
9+
explicit EngineUninstallCmd() : engine_service_{EngineService()} {};
910

10-
void Exec() const;
11+
void Exec(const std::string& engine);
1112

1213
private:
13-
std::string engine_;
14+
EngineService engine_service_;
1415
};
1516
} // namespace commands

engine/commands/model_pull_cmd.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#include "model_pull_cmd.h"
2-
#include <iostream>
32
#include "utils/cortexso_parser.h"
43

54
namespace commands {
6-
bool ModelPullCmd::Exec(const std::string& input) {
7-
return model_service_.DownloadModel(input);
5+
void ModelPullCmd::Exec(const std::string& input) {
6+
model_service_.DownloadModel(input);
87
}
98
}; // namespace commands

engine/commands/model_pull_cmd.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace commands {
66

77
class ModelPullCmd {
88
public:
9-
ModelPullCmd() : model_service_{ModelService()} {};
10-
bool Exec(const std::string& input);
9+
explicit ModelPullCmd() : model_service_{ModelService()} {};
10+
void Exec(const std::string& input);
1111

1212
private:
1313
ModelService model_service_;

0 commit comments

Comments
 (0)