You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 28, 2021. It is now read-only.
There is code to handle std::optionalviaCLARA_CONFIG_OPTIONAL_TYPE; however Opt still is expecting an argument if none is given.
For example for logging: ./program, run with no logging (default), ./program -l enable logging, ./program -l file.log enable logging to named file.
This would make sense to use std::optional here.
For example, the default will not do anything; giving the "flag" -l will act like a pass the log through to std::clog; giving the optional with a filename -l /path/to/file.log will pass through to the /path/to/file.log.
There is code to handle
std::optionalviaCLARA_CONFIG_OPTIONAL_TYPE; howeverOptstill is expecting an argument if none is given.For example for logging:
./program, run with no logging (default),./program -lenable logging,./program -l file.logenable logging to named file.This would make sense to use
std::optionalhere.For example, the default will not do anything; giving the "flag"
-lwill act like a pass the log through tostd::clog; giving the optional with a filename-l /path/to/file.logwill pass through to the/path/to/file.log.std::ostream m_log{nullptr}; std::ofstream m_log_{}; clara::Opt{[&](std::optional<fs::path> filename) { if (!filename) { m_log.rdbuf(std::clog.rdbuf()); return clara::ParserResult::ok(clara::ParseResultType::Matched); } m_log_.open(*filename); m_log.rdbuf(m_log_.rdbuf()); return clara::ParserResult::ok(clara::ParseResultType::Matched); }, "filename"s}["-l"s]["--log"s]("enable logging [set log file {stderr}]"s);