aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/args.hh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-07-14 13:44:45 +0200
committerEelco Dolstra <edolstra@gmail.com>2017-07-14 13:44:45 +0200
commit112ff7833d4f3a233755b2fe856b2eb2b3723254 (patch)
treed07eb31bc6e67c48aa3bd1d0ddaf7f4a6e70f0e4 /src/libutil/args.hh
parent38374a9d35765a1c0b78bfeb02e6f22fc8643e83 (diff)
nix: Show help when no arguments are given
Fixes #1464.
Diffstat (limited to 'src/libutil/args.hh')
-rw-r--r--src/libutil/args.hh5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libutil/args.hh b/src/libutil/args.hh
index aa11373d5..ef8a7953e 100644
--- a/src/libutil/args.hh
+++ b/src/libutil/args.hh
@@ -51,6 +51,7 @@ protected:
{
std::string label;
size_t arity; // 0 = any
+ bool optional;
std::function<void(Strings)> handler;
};
@@ -165,7 +166,7 @@ public:
/* Expect a string argument. */
void expectArg(const std::string & label, string * dest)
{
- expectedArgs.push_back(ExpectedArg{label, 1, [=](Strings ss) {
+ expectedArgs.push_back(ExpectedArg{label, 1, false, [=](Strings ss) {
*dest = ss.front();
}});
}
@@ -173,7 +174,7 @@ public:
/* Expect 0 or more arguments. */
void expectArgs(const std::string & label, Strings * dest)
{
- expectedArgs.push_back(ExpectedArg{label, 0, [=](Strings ss) {
+ expectedArgs.push_back(ExpectedArg{label, 0, false, [=](Strings ss) {
*dest = ss;
}});
}