diff options
author | saturneric <[email protected]> | 2024-01-12 15:08:38 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-01-12 15:08:38 +0000 |
commit | 6983b5c1dd82d159236ebd06cf17f071cc9c1ee9 (patch) | |
tree | fc53f790e33546320b2ecd306a1a9ade6fbdfe7a /src/main.cpp | |
parent | fix: slove a heap-use-after-free issue (diff) | |
download | GpgFrontend-6983b5c1dd82d159236ebd06cf17f071cc9c1ee9.tar.gz GpgFrontend-6983b5c1dd82d159236ebd06cf17f071cc9c1ee9.zip |
refactor: remove boost and use QString instead of std::filesystem::path
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/src/main.cpp b/src/main.cpp index 92ef55ee..700e304e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,11 +30,7 @@ * \mainpage GpgFrontend Develop Document Main Page */ -#include <cstddef> -#include <cstdlib> -#include <iostream> #include <memory> -#include <string> #include "GpgFrontendContext.h" #include "app.h" @@ -42,8 +38,6 @@ #include "core/utils/MemoryUtils.h" #include "init.h" -namespace po = boost::program_options; - /** * * @param argc @@ -61,43 +55,36 @@ auto main(int argc, char* argv[]) -> int { GpgFrontend::GFCxtSPtr ctx = GpgFrontend::SecureCreateSharedObject<GpgFrontend::GpgFrontendContext>( argc, argv); + ctx->InitApplication(); + auto rtn = 0; // initialize qt resources Q_INIT_RESOURCE(gpgfrontend); - po::options_description desc("Allowed options"); + QCommandLineParser parser; + parser.addHelpOption(); + parser.addOptions({ + {{"v", "version"}, "show version information"}, + {{"t", "test"}, "run all unit test cases"}, + {{"l", "log-level"}, + "set log level (trace, debug, info, warn, error)", + "debug"}, + }); - desc.add_options()("help,h", "produce help message")( - "version,v", "show version information")( - "log-level,l", po::value<std::string>()->default_value("info"), - "set log level (trace, debug, info, warn, error)")( - "test,t", "run all unit test cases"); - - po::variables_map vm; - po::store(po::parse_command_line(argc, argv, desc), vm); - po::notify(vm); + parser.process(*ctx->GetApp()); ctx->log_level = spdlog::level::info; - if (vm.count("help") != 0U) { - std::cout << desc << "\n"; - return 0; - } - - if (vm.count("version") != 0U) { + if (parser.isSet("v")) { return GpgFrontend::PrintVersion(); } - if (vm.count("log-level") != 0U) { - ctx->log_level = GpgFrontend::ParseLogLevel(vm); - } - - if (vm.count("log-level") != 0U) { - ctx->log_level = GpgFrontend::ParseLogLevel(vm); + if (parser.isSet("l")) { + ctx->log_level = GpgFrontend::ParseLogLevel(parser.value("l")); } - if (vm.count("test") != 0U) { + if (parser.isSet("t")) { ctx->gather_external_gnupg_info = false; ctx->load_default_gpg_context = false; |