feat: Added --reset-settings
command
This commit is contained in:
parent
a84db9821c
commit
1dfce6a5c2
@ -21,6 +21,7 @@ namespace hex::plugin::builtin {
|
||||
void handlePatternLanguageCommand(const std::vector<std::string> &args);
|
||||
void handleHexdumpCommand(const std::vector<std::string> &args);
|
||||
void handleDemangleCommand(const std::vector<std::string> &args);
|
||||
void handleSettingsResetCommand(const std::vector<std::string> &args);
|
||||
|
||||
|
||||
void registerCommandForwarders();
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "content/command_line_interface.hpp"
|
||||
|
||||
#include <content/command_line_interface.hpp>
|
||||
#include <content/providers/file_provider.hpp>
|
||||
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/api/event_manager.hpp>
|
||||
#include <hex/api/plugin_manager.hpp>
|
||||
@ -351,6 +352,30 @@ namespace hex::plugin::builtin {
|
||||
std::exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
void handleSettingsResetCommand(const std::vector<std::string> &) {
|
||||
constexpr static auto ConfirmationString = "YES I AM ABSOLUTELY SURE";
|
||||
|
||||
log::println("You're about to reset all settings back to their default. Are you sure you want to continue?");
|
||||
log::println("Type \"{}\" to continue.", ConfirmationString);
|
||||
|
||||
std::string input(128, '\x00');
|
||||
|
||||
log::print("> ");
|
||||
std::fgets(input.data(), input.size() - 1, stdin);
|
||||
input = wolv::util::trim(input);
|
||||
|
||||
if (input == ConfirmationString) {
|
||||
log::println("Resetting all settings!");
|
||||
ContentRegistry::Settings::impl::clear();
|
||||
ContentRegistry::Settings::impl::store();
|
||||
|
||||
std::exit(EXIT_SUCCESS);
|
||||
} else {
|
||||
log::println("Wrong confirmation string. Settings will not be reset.");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void registerCommandForwarders() {
|
||||
hex::subcommands::registerSubCommand("open", [](const std::vector<std::string> &args){
|
||||
|
@ -58,22 +58,23 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
IMHEX_PLUGIN_SUBCOMMANDS() {
|
||||
{ "help", "h", "Print help about this command", hex::plugin::builtin::handleHelpCommand },
|
||||
{ "version", "", "Print ImHex version", hex::plugin::builtin::handleVersionCommand },
|
||||
{ "plugins", "", "Lists all plugins that have been installed", hex::plugin::builtin::handlePluginsCommand },
|
||||
{ "language", "", "Changes the language ImHex uses", hex::plugin::builtin::handleLanguageCommand },
|
||||
{ "verbose", "v", "Enables verbose debug logging", hex::plugin::builtin::handleVerboseCommand },
|
||||
{ "help", "h", "Print help about this command", hex::plugin::builtin::handleHelpCommand },
|
||||
{ "version", "", "Print ImHex version", hex::plugin::builtin::handleVersionCommand },
|
||||
{ "plugins", "", "Lists all plugins that have been installed", hex::plugin::builtin::handlePluginsCommand },
|
||||
{ "language", "", "Changes the language ImHex uses", hex::plugin::builtin::handleLanguageCommand },
|
||||
{ "verbose", "v", "Enables verbose debug logging", hex::plugin::builtin::handleVerboseCommand },
|
||||
|
||||
{ "open", "o", "Open files passed as argument. [default]", hex::plugin::builtin::handleOpenCommand },
|
||||
{ "open", "o", "Open files passed as argument. [default]", hex::plugin::builtin::handleOpenCommand },
|
||||
|
||||
{ "calc", "", "Evaluate a mathematical expression", hex::plugin::builtin::handleCalcCommand },
|
||||
{ "hash", "", "Calculate the hash of a file", hex::plugin::builtin::handleHashCommand },
|
||||
{ "encode", "", "Encode a string", hex::plugin::builtin::handleEncodeCommand },
|
||||
{ "decode", "", "Decode a string", hex::plugin::builtin::handleDecodeCommand },
|
||||
{ "magic", "", "Identify file types", hex::plugin::builtin::handleMagicCommand },
|
||||
{ "pl", "", "Interact with the pattern language", hex::plugin::builtin::handlePatternLanguageCommand },
|
||||
{ "hexdump", "", "Generate a hex dump of the provided file", hex::plugin::builtin::handleHexdumpCommand },
|
||||
{ "demangle", "", "Demangle a mangled symbol", hex::plugin::builtin::handleDemangleCommand },
|
||||
{ "calc", "", "Evaluate a mathematical expression", hex::plugin::builtin::handleCalcCommand },
|
||||
{ "hash", "", "Calculate the hash of a file", hex::plugin::builtin::handleHashCommand },
|
||||
{ "encode", "", "Encode a string", hex::plugin::builtin::handleEncodeCommand },
|
||||
{ "decode", "", "Decode a string", hex::plugin::builtin::handleDecodeCommand },
|
||||
{ "magic", "", "Identify file types", hex::plugin::builtin::handleMagicCommand },
|
||||
{ "pl", "", "Interact with the pattern language", hex::plugin::builtin::handlePatternLanguageCommand },
|
||||
{ "hexdump", "", "Generate a hex dump of the provided file", hex::plugin::builtin::handleHexdumpCommand },
|
||||
{ "demangle", "", "Demangle a mangled symbol", hex::plugin::builtin::handleDemangleCommand },
|
||||
{ "reset-settings", "", "Demangle a mangled symbol", hex::plugin::builtin::handleSettingsResetCommand },
|
||||
};
|
||||
|
||||
IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user