1
0
mirror of synced 2025-02-11 16:22:59 +01:00

feat: Added separate --version-short command

This commit is contained in:
WerWolv 2025-02-07 15:46:11 +01:00
parent ed6da7fe14
commit e63606f6bb
3 changed files with 15 additions and 11 deletions

View File

@ -6,6 +6,7 @@
namespace hex::plugin::builtin { namespace hex::plugin::builtin {
void handleVersionCommand(const std::vector<std::string> &args); void handleVersionCommand(const std::vector<std::string> &args);
void handleVersionShortCommand(const std::vector<std::string> &args);
void handleHelpCommand(const std::vector<std::string> &args); void handleHelpCommand(const std::vector<std::string> &args);
void handlePluginsCommand(const std::vector<std::string> &args); void handlePluginsCommand(const std::vector<std::string> &args);
void handleLanguageCommand(const std::vector<std::string> &args); void handleLanguageCommand(const std::vector<std::string> &args);

View File

@ -30,18 +30,20 @@ namespace hex::plugin::builtin {
using namespace hex::literals; using namespace hex::literals;
void handleVersionCommand(const std::vector<std::string> &args) { void handleVersionCommand(const std::vector<std::string> &args) {
if (args.empty()) { std::ignore = args;
hex::log::print(std::string(romfs::get("logo.ans").string()),
ImHexApi::System::getImHexVersion().get(),
ImHexApi::System::getCommitBranch(), ImHexApi::System::getCommitHash(),
__DATE__, __TIME__,
ImHexApi::System::isPortableVersion() ? "Portable" : "Installed");
} else if (args.size() == 1 && args[0] == "plain") {
hex::log::print("{}", ImHexApi::System::getImHexVersion().get());
} else {
std::exit(EXIT_FAILURE);
}
hex::log::print(std::string(romfs::get("logo.ans").string()),
ImHexApi::System::getImHexVersion().get(),
ImHexApi::System::getCommitBranch(), ImHexApi::System::getCommitHash(),
__DATE__, __TIME__,
ImHexApi::System::isPortableVersion() ? "Portable" : "Installed");
std::exit(EXIT_SUCCESS);
}
void handleVersionShortCommand(const std::vector<std::string> &args) {
std::ignore = args;
hex::log::println("{}", ImHexApi::System::getImHexVersion().get());
std::exit(EXIT_SUCCESS); std::exit(EXIT_SUCCESS);
} }

View File

@ -64,6 +64,7 @@ namespace hex::plugin::builtin {
IMHEX_PLUGIN_SUBCOMMANDS() { IMHEX_PLUGIN_SUBCOMMANDS() {
{ "help", "h", "Print help about this command", hex::plugin::builtin::handleHelpCommand }, { "help", "h", "Print help about this command", hex::plugin::builtin::handleHelpCommand },
{ "version", "", "Print ImHex version", hex::plugin::builtin::handleVersionCommand }, { "version", "", "Print ImHex version", hex::plugin::builtin::handleVersionCommand },
{ "version-short", "", "Print only the version info in plain text", hex::plugin::builtin::handleVersionShortCommand },
{ "plugins", "", "Lists all plugins that have been installed", hex::plugin::builtin::handlePluginsCommand }, { "plugins", "", "Lists all plugins that have been installed", hex::plugin::builtin::handlePluginsCommand },
{ "language", "", "Changes the language ImHex uses", hex::plugin::builtin::handleLanguageCommand }, { "language", "", "Changes the language ImHex uses", hex::plugin::builtin::handleLanguageCommand },
{ "verbose", "v", "Enables verbose debug logging", hex::plugin::builtin::handleVerboseCommand }, { "verbose", "v", "Enables verbose debug logging", hex::plugin::builtin::handleVerboseCommand },