diff options
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/args.cc | 1 | ||||
-rw-r--r-- | src/libutil/args.hh | 4 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/libutil/args.cc b/src/libutil/args.cc index 0eed49454..19a45d7e9 100644 --- a/src/libutil/args.cc +++ b/src/libutil/args.cc @@ -66,6 +66,7 @@ void Args::printHelp(const string & programName, std::ostream & out) std::cout << renderLabels({exp.label}); // FIXME: handle arity > 1 if (exp.arity == 0) std::cout << "..."; + if (exp.optional) std::cout << "?"; } std::cout << "\n"; diff --git a/src/libutil/args.hh b/src/libutil/args.hh index ef8a7953e..37e780dd1 100644 --- a/src/libutil/args.hh +++ b/src/libutil/args.hh @@ -164,9 +164,9 @@ public: } /* Expect a string argument. */ - void expectArg(const std::string & label, string * dest) + void expectArg(const std::string & label, string * dest, bool optional = false) { - expectedArgs.push_back(ExpectedArg{label, 1, false, [=](Strings ss) { + expectedArgs.push_back(ExpectedArg{label, 1, optional, [=](Strings ss) { *dest = ss.front(); }}); } |