diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2017-06-22 01:55:54 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2017-06-22 01:55:54 +0300 |
commit | 58abcc99fcd663435d32c71c90816c8a07081a47 (patch) | |
tree | b32ab9b60c01ac860a66369923c0953843f935d3 /utils/enum_symbols.cpp | |
parent | fix a CMake warning (diff) | |
download | winapi-debug-58abcc99fcd663435d32c71c90816c8a07081a47.tar.gz winapi-debug-58abcc99fcd663435d32c71c90816c8a07081a47.zip |
refactor command-line parameters parsing
Diffstat (limited to 'utils/enum_symbols.cpp')
-rw-r--r-- | utils/enum_symbols.cpp | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/utils/enum_symbols.cpp b/utils/enum_symbols.cpp index 848c523..8fa0960 100644 --- a/utils/enum_symbols.cpp +++ b/utils/enum_symbols.cpp @@ -23,10 +23,19 @@ namespace { public: explicit EnumSymbols(const std::string& argv0) - : SettingsParser{argv0, build_options()} - { } - - bool exit_with_usage() const { return help_flag; } + : SettingsParser{argv0} + { + visible.add_options() + ("pdb", + boost::program_options::value<std::vector<PDB>>(&pdbs) + ->value_name("ADDR,PATH"), + "load a PDB file") + ("functions", + boost::program_options::value<pdb::Symbol::Tag>(&tag) + ->implicit_value(function_tag) + ->zero_tokens(), + "only list functions"); + } const char* get_short_description() const override { @@ -46,28 +55,6 @@ namespace } private: - Options build_options() - { - namespace program_options = boost::program_options; - Options descr{"options"}; - descr.add_options() - ("help,h", - program_options::bool_switch(&help_flag), - "show this message and exit") - ("pdb", - program_options::value<std::vector<PDB>>(&pdbs) - ->value_name("ADDR,PATH"), - "load a PDB file") - ("functions", - program_options::value<pdb::Symbol::Tag>(&tag) - ->implicit_value(function_tag) - ->zero_tokens(), - "only list functions"); - return descr; - } - - bool help_flag = false; - static const auto reserved_tag = static_cast<pdb::Symbol::Tag>(pdb::Symbol::Type::RESERVED); static const auto function_tag = static_cast<pdb::Symbol::Tag>(pdb::Symbol::Type::Function); @@ -79,7 +66,7 @@ int main(int argc, char* argv[]) { try { - const EnumSymbols settings{argv[0]}; + EnumSymbols settings{argv[0]}; try { @@ -91,7 +78,7 @@ int main(int argc, char* argv[]) return 1; } - if (settings.exit_with_usage()) + if (settings.exit_with_usage) { settings.usage(); return 0; |