mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
feat: Added Auto Updater for Windows, macOS and Ubuntu (#1377)
This commit is contained in:
@@ -26,7 +26,7 @@ namespace hex::plugin::builtin {
|
||||
void handleVersionCommand(const std::vector<std::string> &args) {
|
||||
hex::unused(args);
|
||||
|
||||
hex::print(romfs::get("logo.ans").string(),
|
||||
hex::log::print(std::string(romfs::get("logo.ans").string()),
|
||||
ImHexApi::System::getImHexVersion(),
|
||||
ImHexApi::System::getCommitBranch(), ImHexApi::System::getCommitHash(),
|
||||
__DATE__, __TIME__,
|
||||
@@ -38,7 +38,7 @@ namespace hex::plugin::builtin {
|
||||
void handleHelpCommand(const std::vector<std::string> &args) {
|
||||
hex::unused(args);
|
||||
|
||||
hex::print(
|
||||
hex::log::print(
|
||||
"ImHex - A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.\n"
|
||||
"\n"
|
||||
"usage: imhex [subcommand] [options]\n"
|
||||
@@ -54,7 +54,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
for (const auto &plugin : PluginManager::getPlugins()) {
|
||||
for (const auto &subCommand : plugin.getSubCommands()) {
|
||||
hex::println(" --{}{: <{}} {}", subCommand.commandKey, "", longestCommand - subCommand.commandKey.size(), subCommand.commandDesc);
|
||||
hex::log::println(" --{}{: <{}} {}", subCommand.commandKey, "", longestCommand - subCommand.commandKey.size(), subCommand.commandDesc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void handleOpenCommand(const std::vector<std::string> &args) {
|
||||
if (args.empty()) {
|
||||
hex::println("No files provided to open.");
|
||||
hex::log::println("No files provided to open.");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void handleCalcCommand(const std::vector<std::string> &args) {
|
||||
if (args.empty()) {
|
||||
hex::println("No expression provided!");
|
||||
hex::println("Example: imhex --calc \"5 * 7\"");
|
||||
hex::log::println("No expression provided!");
|
||||
hex::log::println("Example: imhex --calc \"5 * 7\"");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -100,9 +100,9 @@ namespace hex::plugin::builtin {
|
||||
auto result = evaluator.evaluate(input);
|
||||
|
||||
if (!result.has_value())
|
||||
hex::println("{}\n> '{}'", evaluator.getLastError().value(), input);
|
||||
hex::log::println("{}\n> '{}'", evaluator.getLastError().value(), input);
|
||||
else
|
||||
hex::println("{}", result.value());
|
||||
hex::log::println("{}", result.value());
|
||||
|
||||
std::exit(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -110,19 +110,19 @@ namespace hex::plugin::builtin {
|
||||
void handlePluginsCommand(const std::vector<std::string> &args) {
|
||||
hex::unused(args);
|
||||
|
||||
hex::println("Loaded plugins:");
|
||||
hex::log::println("Loaded plugins:");
|
||||
|
||||
for (const auto &plugin : PluginManager::getPlugins()) {
|
||||
hex::print("- ");
|
||||
hex::log::print("- ");
|
||||
|
||||
if (plugin.isBuiltinPlugin())
|
||||
hex::print("\033[1;43m{}\033[0m", plugin.getPluginName());
|
||||
hex::log::print("\033[1;43m{}\033[0m", plugin.getPluginName());
|
||||
else
|
||||
hex::print("\033[1m{}\033[0m", plugin.getPluginName());
|
||||
hex::log::print("\033[1m{}\033[0m", plugin.getPluginName());
|
||||
|
||||
hex::println(" by {}", plugin.getPluginAuthor());
|
||||
hex::log::println(" by {}", plugin.getPluginAuthor());
|
||||
|
||||
hex::println(" \033[2;3m{}\033[0m", plugin.getPluginDescription());
|
||||
hex::log::println(" \033[2;3m{}\033[0m", plugin.getPluginDescription());
|
||||
}
|
||||
|
||||
std::exit(EXIT_SUCCESS);
|
||||
@@ -130,8 +130,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void handleHashCommand(const std::vector<std::string> &args) {
|
||||
if (args.size() != 2) {
|
||||
hex::println("usage: imhex --hash <algorithm> <file>");
|
||||
hex::println("Available algorithms: md5, sha1, sha224, sha256, sha384, sha512");
|
||||
hex::log::println("usage: imhex --hash <algorithm> <file>");
|
||||
hex::log::println("Available algorithms: md5, sha1, sha224, sha256, sha384, sha512");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
wolv::io::File file(filePath, wolv::io::File::Mode::Read);
|
||||
if (!file.isValid()) {
|
||||
hex::println("Failed to open file: {}", wolv::util::toUTF8String(filePath));
|
||||
hex::log::println("Failed to open file: {}", wolv::util::toUTF8String(filePath));
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -162,20 +162,20 @@ namespace hex::plugin::builtin {
|
||||
} else if (algorithm == "sha512") {
|
||||
result = toVector(hex::crypt::sha512(file.readVector()));
|
||||
} else {
|
||||
hex::println("Unknown algorithm: {}", algorithm);
|
||||
hex::println("Available algorithms: md5, sha1, sha224, sha256, sha384, sha512");
|
||||
hex::log::println("Unknown algorithm: {}", algorithm);
|
||||
hex::log::println("Available algorithms: md5, sha1, sha224, sha256, sha384, sha512");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
hex::println("{}({}) = {}", algorithm, wolv::util::toUTF8String(filePath.filename()), hex::crypt::encode16(result));
|
||||
hex::log::println("{}({}) = {}", algorithm, wolv::util::toUTF8String(filePath.filename()), hex::crypt::encode16(result));
|
||||
|
||||
std::exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
void handleEncodeCommand(const std::vector<std::string> &args) {
|
||||
if (args.size() != 2) {
|
||||
hex::println("usage: imhex --encode <algorithm> <string>");
|
||||
hex::println("Available algorithms: base64, hex");
|
||||
hex::log::println("usage: imhex --encode <algorithm> <string>");
|
||||
hex::log::println("Available algorithms: base64, hex");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -189,19 +189,19 @@ namespace hex::plugin::builtin {
|
||||
} else if (algorithm == "hex") {
|
||||
result = hex::crypt::encode16(data);
|
||||
} else {
|
||||
hex::println("Unknown algorithm: {}", algorithm);
|
||||
hex::println("Available algorithms: base64, hex");
|
||||
hex::log::println("Unknown algorithm: {}", algorithm);
|
||||
hex::log::println("Available algorithms: base64, hex");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
hex::println("encode_{}({}) = {}", algorithm, args[1], result);
|
||||
hex::log::println("encode_{}({}) = {}", algorithm, args[1], result);
|
||||
std::exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
void handleDecodeCommand(const std::vector<std::string> &args) {
|
||||
if (args.size() != 2) {
|
||||
hex::println("usage: imhex --decode <algorithm> <string>");
|
||||
hex::println("Available algorithms: base64, hex");
|
||||
hex::log::println("usage: imhex --decode <algorithm> <string>");
|
||||
hex::log::println("Available algorithms: base64, hex");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -216,24 +216,24 @@ namespace hex::plugin::builtin {
|
||||
auto base16 = hex::crypt::decode16(std::string(data.begin(), data.end()));
|
||||
result = std::string(base16.begin(), base16.end());
|
||||
} else {
|
||||
hex::println("Unknown algorithm: {}", algorithm);
|
||||
hex::println("Available algorithms: base64, hex");
|
||||
hex::log::println("Unknown algorithm: {}", algorithm);
|
||||
hex::log::println("Available algorithms: base64, hex");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
hex::print("decode_{}({}) = {}", algorithm, args[1], result);
|
||||
hex::log::print("decode_{}({}) = {}", algorithm, args[1], result);
|
||||
std::exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
void handleMagicCommand(const std::vector<std::string> &args) {
|
||||
if (args.size() != 2) {
|
||||
hex::println("usage: imhex --magic <operation> <file>");
|
||||
hex::println("Available operations: mime, desc");
|
||||
hex::log::println("usage: imhex --magic <operation> <file>");
|
||||
hex::log::println("Available operations: mime, desc");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!magic::compile()) {
|
||||
hex::print("Failed to compile magic database!");
|
||||
hex::log::print("Failed to compile magic database!");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
wolv::io::File file(filePath, wolv::io::File::Mode::Read);
|
||||
if (!file.isValid()) {
|
||||
hex::println("Failed to open file: {}", wolv::util::toUTF8String(filePath));
|
||||
hex::log::println("Failed to open file: {}", wolv::util::toUTF8String(filePath));
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -250,13 +250,13 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (operation == "mime") {
|
||||
auto result = magic::getMIMEType(data);
|
||||
hex::println("{}", result);
|
||||
hex::log::println("{}", result);
|
||||
} else if (operation == "desc") {
|
||||
auto result = magic::getDescription(data);
|
||||
hex::println("{}", result);
|
||||
hex::log::println("{}", result);
|
||||
} else {
|
||||
hex::println("Unknown operation: {}", operation);
|
||||
hex::println("Available operations: mime, desc");
|
||||
hex::log::println("Unknown operation: {}", operation);
|
||||
hex::log::println("Available operations: mime, desc");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user