1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-29 23:13:14 +02:00

nix: Show help when no arguments are given

Fixes #1464.
This commit is contained in:
Eelco Dolstra 2017-07-14 13:44:45 +02:00
parent 38374a9d35
commit 112ff7833d
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
4 changed files with 14 additions and 10 deletions

View file

@ -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;
}});
}