diff options
Diffstat (limited to 'argument.cpp')
-rw-r--r-- | argument.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/argument.cpp b/argument.cpp index 41cf6f7..d388001 100644 --- a/argument.cpp +++ b/argument.cpp @@ -37,6 +37,7 @@ const option ArgumentParser::options[] = { "key", required_argument, nullptr, 'k' }, { "polarity", required_argument, nullptr, 'r' }, { "target", required_argument, nullptr, 't' }, + { "continue", optional_argument, nullptr, 'c' }, { "help", no_argument, nullptr, 'h' }, { 0, 0, 0, 0}, }; @@ -60,7 +61,10 @@ ArgumentParser::ArgumentParser(int argc, char** argv) if (i->val) { - arguments[i->name] = (i->has_arg ? optarg : trueString); + // optinal argument may get nullptr for optarg + // make it empty string in such case + auto arg = (optarg == nullptr ? "" : optarg); + arguments[i->name] = (i->has_arg ? arg : trueString); } } } @@ -90,6 +94,8 @@ void ArgumentParser::usage(char** argv) " This is 0 / 1 \n"; std::cerr << " --target=<systemd unit> Systemd unit to be called on GPIO" " state change\n"; + std::cerr << " --continue=[true] Whether or not to continue" + " after key pressed\n"; } } // namespace gpio } // namespace phosphor |