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

Commit 1a54729

Browse files
committed
add filter for variant list
1 parent b326574 commit 1a54729

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

engine/cli/commands/engine_install_cmd.cc

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,12 @@
44
#include "utils/cli_selection_utils.h"
55
#include "utils/download_progress.h"
66
#include "utils/logging_utils.h"
7+
#include "utils/string_utils.h"
78

89
namespace commands {
910
bool EngineInstallCmd::Exec(const std::string& engine,
1011
const std::string& version,
1112
const std::string& src) {
12-
// Start server if server is not started yet
13-
if (!commands::IsServerAlive(host_, port_)) {
14-
CLI_LOG("Starting server ...");
15-
commands::ServerStartCmd ssc;
16-
if (!ssc.Exec(host_, port_)) {
17-
return false;
18-
}
19-
}
2013
// Handle local install, if fails, fallback to remote install
2114
if (!src.empty()) {
2215
auto res = engine_service_.UnzipEngine(engine, version, src);
@@ -30,6 +23,15 @@ bool EngineInstallCmd::Exec(const std::string& engine,
3023
}
3124
}
3225

26+
// Start server if server is not started yet
27+
if (!commands::IsServerAlive(host_, port_)) {
28+
CLI_LOG("Starting server ...");
29+
commands::ServerStartCmd ssc;
30+
if (!ssc.Exec(host_, port_)) {
31+
return false;
32+
}
33+
}
34+
3335
if (show_menu_) {
3436
DownloadProgress dp;
3537
dp.Connect(host_, port_);
@@ -81,7 +83,10 @@ bool EngineInstallCmd::Exec(const std::string& engine,
8183

8284
std::vector<std::string> variant_selections;
8385
for (const auto& variant : variant_result.value()) {
84-
variant_selections.push_back(variant["name"].asString());
86+
auto v_name = variant["name"].asString();
87+
if (string_utils::StringContainsIgnoreCase(v_name, hw_inf_.sys_inf->os)) {
88+
variant_selections.push_back(variant["name"].asString());
89+
}
8590
}
8691
auto selected_variant =
8792
cli_selection_utils::PrintSelection(variant_selections);

engine/cli/commands/engine_install_cmd.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ class EngineInstallCmd {
1212
: engine_service_{EngineService(download_service)},
1313
host_(host),
1414
port_(port),
15-
show_menu_(show_menu) {};
15+
show_menu_(show_menu),
16+
hw_inf_{.sys_inf = system_info_utils::GetSystemInfo(),
17+
.cuda_driver_version = system_info_utils::GetCudaVersion()} {};
1618

1719
bool Exec(const std::string& engine, const std::string& version = "latest",
1820
const std::string& src = "");
@@ -22,5 +24,12 @@ class EngineInstallCmd {
2224
std::string host_;
2325
int port_;
2426
bool show_menu_;
27+
28+
struct HardwareInfo {
29+
std::unique_ptr<system_info_utils::SystemInfo> sys_inf;
30+
cortex::cpuid::CpuInfo cpu_inf;
31+
std::string cuda_driver_version;
32+
};
33+
HardwareInfo hw_inf_;
2534
};
2635
} // namespace commands

0 commit comments

Comments
 (0)