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 handlePatternLanguageCommand(const std::vector<std::string> &args);
|
||||||
void handleHexdumpCommand(const std::vector<std::string> &args);
|
void handleHexdumpCommand(const std::vector<std::string> &args);
|
||||||
void handleDemangleCommand(const std::vector<std::string> &args);
|
void handleDemangleCommand(const std::vector<std::string> &args);
|
||||||
|
void handleSettingsResetCommand(const std::vector<std::string> &args);
|
||||||
|
|
||||||
|
|
||||||
void registerCommandForwarders();
|
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 <content/providers/file_provider.hpp>
|
||||||
|
|
||||||
|
#include <hex/api/content_registry.hpp>
|
||||||
#include <hex/api/imhex_api.hpp>
|
#include <hex/api/imhex_api.hpp>
|
||||||
#include <hex/api/event_manager.hpp>
|
#include <hex/api/event_manager.hpp>
|
||||||
#include <hex/api/plugin_manager.hpp>
|
#include <hex/api/plugin_manager.hpp>
|
||||||
@ -351,6 +352,30 @@ namespace hex::plugin::builtin {
|
|||||||
std::exit(EXIT_SUCCESS);
|
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() {
|
void registerCommandForwarders() {
|
||||||
hex::subcommands::registerSubCommand("open", [](const std::vector<std::string> &args){
|
hex::subcommands::registerSubCommand("open", [](const std::vector<std::string> &args){
|
||||||
|
@ -74,6 +74,7 @@ IMHEX_PLUGIN_SUBCOMMANDS() {
|
|||||||
{ "pl", "", "Interact with the pattern language", hex::plugin::builtin::handlePatternLanguageCommand },
|
{ "pl", "", "Interact with the pattern language", hex::plugin::builtin::handlePatternLanguageCommand },
|
||||||
{ "hexdump", "", "Generate a hex dump of the provided file", hex::plugin::builtin::handleHexdumpCommand },
|
{ "hexdump", "", "Generate a hex dump of the provided file", hex::plugin::builtin::handleHexdumpCommand },
|
||||||
{ "demangle", "", "Demangle a mangled symbol", hex::plugin::builtin::handleDemangleCommand },
|
{ "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") {
|
IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user