-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1094 from janhq/feat/engine-uninstall
feat: add engine uninstall command
- Loading branch information
Showing
25 changed files
with
566 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "engine_get_cmd.h" | ||
#include <iostream> | ||
#include <tabulate/table.hpp> | ||
#include "services/engine_service.h" | ||
#include "utils/logging_utils.h" | ||
|
||
namespace commands { | ||
|
||
void EngineGetCmd::Exec() const { | ||
CTL_INF("[EngineGetCmd] engine: " << engine_); | ||
|
||
auto engine_service = EngineService(); | ||
try { | ||
auto status = engine_service.GetEngineInfo(engine_); | ||
tabulate::Table table; | ||
table.add_row({"name", "description", "version", "product name", "status"}); | ||
table.format().font_color(tabulate::Color::green); | ||
table.add_row({status.name, status.description, status.version, | ||
status.product_name, status.status}); | ||
std::cout << table << std::endl; | ||
} catch (const std::runtime_error& e) { | ||
std::cerr << "Engine " << engine_ << " is not supported!" << "\n"; | ||
} catch (const std::exception& e) { | ||
std::cerr << "Failed to get engine info for " << engine_ << ": " << e.what() | ||
<< "\n"; | ||
} | ||
} | ||
}; // namespace commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace commands { | ||
class EngineGetCmd { | ||
public: | ||
EngineGetCmd(const std::string& engine) : engine_{engine} {}; | ||
|
||
void Exec() const; | ||
|
||
private: | ||
std::string engine_; | ||
}; | ||
} // namespace commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace commands { | ||
class EngineListCmd { | ||
public: | ||
bool Exec() ; | ||
bool Exec(); | ||
}; | ||
|
||
} // namespace commands | ||
} // namespace commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "engine_uninstall_cmd.h" | ||
#include "services/engine_service.h" | ||
#include "utils/logging_utils.h" | ||
|
||
namespace commands { | ||
|
||
EngineUninstallCmd::EngineUninstallCmd(std::string engine) | ||
: engine_{std::move(engine)} {} | ||
|
||
void EngineUninstallCmd::Exec() const { | ||
CTL_INF("Uninstall engine " + engine_); | ||
auto engine_service = EngineService(); | ||
|
||
try { | ||
engine_service.UninstallEngine(engine_); | ||
CLI_LOG("Engine " << engine_ << " uninstalled successfully!") | ||
} catch (const std::exception& e) { | ||
CLI_LOG("Failed to uninstall engine " << engine_ << ": " << e.what()); | ||
} | ||
} | ||
}; // namespace commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace commands { | ||
class EngineUninstallCmd { | ||
public: | ||
EngineUninstallCmd(std::string engine); | ||
|
||
void Exec() const; | ||
|
||
private: | ||
std::string engine_; | ||
}; | ||
} // namespace commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,4 @@ bool ModelStartCmd::Exec() { | |
return true; | ||
} | ||
|
||
}; // namespace commands | ||
}; // namespace commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
#pragma once | ||
#include <string> | ||
#include <optional> | ||
#include "config/model_config.h" | ||
|
||
namespace commands { | ||
|
||
class ModelStartCmd{ | ||
class ModelStartCmd { | ||
public: | ||
explicit ModelStartCmd(std::string host, int port, const config::ModelConfig& mc); | ||
explicit ModelStartCmd(std::string host, int port, | ||
const config::ModelConfig& mc); | ||
bool Exec(); | ||
|
||
private: | ||
std::string host_; | ||
int port_; | ||
const config::ModelConfig& mc_; | ||
}; | ||
} // namespace commands | ||
} // namespace commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.