Enhanced CLI parsing to allow non-option values
This commit is contained in:
@ -49,7 +49,27 @@ CLIParser::CLIParser(int argc, char *argv[])
|
||||
|
||||
build();
|
||||
try {
|
||||
po::store(po::parse_command_line(argc, argv, desc), vm_); // can throw
|
||||
// Variant 1: no non-options
|
||||
//po::store(po::parse_command_line(argc, argv, desc), vm_); // can throw
|
||||
// Variant 2: collect unrecognized options
|
||||
//auto parsed = po::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
|
||||
//po::store(parsed, vm_); // can throw
|
||||
// Variant 3: collect options in string vector
|
||||
po::options_description hidden;
|
||||
hidden.add_options()("argv", po::value<std::vector<std::string>>(), "arguments");
|
||||
|
||||
po::options_description all_opt;
|
||||
po::positional_options_description posopt;
|
||||
po::store(po::command_line_parser(argc, argv).
|
||||
options(all_opt.add(desc).add(hidden)).
|
||||
//allow_unregistered().
|
||||
positional(posopt.add("argv", -1)).
|
||||
// style(
|
||||
// po::command_line_style::default_style |
|
||||
// po::command_line_style::allow_slash_for_short).
|
||||
run(),
|
||||
vm_); // can throw
|
||||
|
||||
// --help option
|
||||
if (vm_.count("help")) {
|
||||
std::cout << "DBT-RISE-RiscV simulator for RISC-V" << std::endl << desc << std::endl;
|
||||
|
@ -108,7 +108,13 @@ int sc_main(int argc, char *argv[]) {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
cfg.set_value("i_system.i_hifive1.i_fe310.i_core_complex.gdb_server_port", parser.get<unsigned short>("gdb-port"));
|
||||
cfg.set_value("i_system.i_hifive1.i_fe310.i_core_complex.dump_ir", parser.is_set("dump-ir"));
|
||||
if (parser.is_set("elf")) cfg.set_value("i_system.i_hifive1.i_fe310.i_core_complex.elf_file", parser.get<std::string>("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"));
|
||||
else {
|
||||
auto args = parser.get<std::vector<std::string>>("argv");
|
||||
if(args.size())
|
||||
cfg.set_value("i_system.i_hifive1.i_fe310.i_core_complex.elf_file", args[0]);
|
||||
}
|
||||
if (parser.is_set("quantum"))
|
||||
tlm::tlm_global_quantum::instance().set(sc_core::sc_time(parser.get<unsigned>("quantum"), sc_core::SC_NS));
|
||||
if (parser.is_set("reset")) {
|
||||
|
Reference in New Issue
Block a user