p-ranav/structopt

Exception without try catch?

ru108 opened this issue · 1 comments

ru108 commented
#include <iostream>
#include <optional>
#include <string>

#include <structopt/app.hpp>

struct Options {
  std::string db_name;
  std::string path_files;
  std::string path_archive;
  enum class LogLevel { trace, debug, info, warn, err, critical, off };
  std::optional<LogLevel> log_level = LogLevel::debug;
};
STRUCTOPT(Options, db_name, path_files, path_archive, log_level);

int main(int argc, char* argv[]) {
  auto opts = structopt::app("test", "1.0.0.1").parse<Options>(argc, argv);

  std::cout << "Hello World!\n";
}

without parameters
./test.exe

Microsoft Visual Studio Community 2019
Version 16.7.2
VisualStudio.16.Release/16.7.2+30413.136

ru108 commented

I know that wrong args but...
./test.exe --db_name=qqq --path_files=rrr --path_archive=uuu
infinity loop in

for (std::size_t i = 1; i < parser.arguments.size(); i++) {
parser.current_index = i;
visit_struct::for_each(argument_struct, parser);
}