fix help switch

This commit is contained in:
Stanislaw Kaushanski 2020-06-25 08:27:29 +02:00
parent 3cdc7431ad
commit 7402a19732
2 changed files with 5 additions and 4 deletions

View File

@ -68,6 +68,7 @@ CLIParser::CLIParser(int argc, char *argv[])
// --help option // --help option
if (vm_.count("help")) { if (vm_.count("help")) {
std::cout << "DBT-RISE-RiscV simulator for RISC-V" << std::endl << desc << std::endl; std::cout << "DBT-RISE-RiscV simulator for RISC-V" << std::endl << desc << std::endl;
exit(0);
} }
po::notify(vm_); // throws on error, so do after help in case there are any problems po::notify(vm_); // throws on error, so do after help in case there are any problems
valid = true; valid = true;
@ -76,7 +77,7 @@ CLIParser::CLIParser(int argc, char *argv[])
std::cerr << desc << std::endl; std::cerr << desc << std::endl;
} }
auto verbosity = !vm_["Verbose"].defaulted() ? vm_["Verbose"].as<unsigned>() : vm_["verbose"].as<unsigned>(); auto verbosity = !vm_["Verbose"].defaulted() ? vm_["Verbose"].as<unsigned>() : vm_.count("verbose") ? vm_["verbose"].as<unsigned>() : 3;
auto colored_output = vm_["Verbose"].defaulted(); auto colored_output = vm_["Verbose"].defaulted();
auto dbg_level = vm_.count("debug-level") auto dbg_level = vm_.count("debug-level")
? vm_["debug-level"].as<scc::log>() ? vm_["debug-level"].as<scc::log>()
@ -109,7 +110,7 @@ void CLIParser::build() {
// clang-format off // clang-format off
desc.add_options() desc.add_options()
("help,h", "Print help message") ("help,h", "Print help message")
("verbose,v", po::value<unsigned>()->implicit_value(3), "Sets logging verbosity") ("verbose,v", po::value<unsigned>()->implicit_value(4), "Sets logging verbosity")
("Verbose,V", po::value<unsigned>()->default_value(logging::INFO), "Debug output level as with --verbose but print non-colored") ("Verbose,V", po::value<unsigned>()->default_value(logging::INFO), "Debug output level as with --verbose but print non-colored")
("debug-level,D", po::value<scc::log>(), "Debug output level (textual) as with --verbose") ("debug-level,D", po::value<scc::log>(), "Debug output level (textual) as with --verbose")
("log-file", po::value<std::string>(), "Sets default log file.") ("log-file", po::value<std::string>(), "Sets default log file.")

View File

@ -69,9 +69,9 @@ int sc_main(int argc, char *argv[]) {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// CLI argument parsing & logging setup // CLI argument parsing & logging setup
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
CLIParser parser(argc, argv);
scc::stream_redirection cout_redir(std::cout, scc::log::INFO); scc::stream_redirection cout_redir(std::cout, scc::log::INFO);
scc::stream_redirection cerr_redir(std::cerr, scc::log::ERROR); scc::stream_redirection cerr_redir(std::cerr, scc::log::ERROR);
CLIParser parser(argc, argv);
if (!parser.is_valid()) return ERROR_IN_COMMAND_LINE; if (!parser.is_valid()) return ERROR_IN_COMMAND_LINE;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// set up infrastructure // set up infrastructure
@ -116,7 +116,7 @@ int sc_main(int argc, char *argv[]) {
cfg.set_value("i_system.i_hifive1.i_fe310.i_core_complex.dump_ir", parser.is_set("dump-ir")); cfg.set_value("i_system.i_hifive1.i_fe310.i_core_complex.dump_ir", parser.is_set("dump-ir"));
if (parser.is_set("elf")) if (parser.is_set("elf"))
cfg.set_value("i_system.i_hifive1.i_fe310.i_core_complex.elf_file", parser.get<std::string>("elf")); cfg.set_value("i_system.i_hifive1.i_fe310.i_core_complex.elf_file", parser.get<std::string>("elf"));
else { else if (parser.is_set("argv")){
auto args = parser.get<std::vector<std::string>>("argv"); auto args = parser.get<std::vector<std::string>>("argv");
if(args.size()) if(args.size())
cfg.set_value("i_system.i_hifive1.i_fe310.i_core_complex.elf_file", args[0]); cfg.set_value("i_system.i_hifive1.i_fe310.i_core_complex.elf_file", args[0]);