diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-10-24T10·45+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-10-24T10·58+0200 |
commit | 0d59f1ca49c9f7f3b2edaadcf590360ec66a6257 (patch) | |
tree | a03d53d84fb61eb354e2634705d8a076f0c1c76d /src/libmain/common-args.cc | |
parent | 25f32625e2f2a3a1e1b3a3811da82f21c3a3b880 (diff) |
nix: Respect -I, --arg, --argstr
Also, random cleanup to argument handling.
Diffstat (limited to 'src/libmain/common-args.cc')
-rw-r--r-- | src/libmain/common-args.cc | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/libmain/common-args.cc b/src/libmain/common-args.cc index 3fa42c2aafa9..ea27aaa35e03 100644 --- a/src/libmain/common-args.cc +++ b/src/libmain/common-args.cc @@ -6,28 +6,30 @@ namespace nix { MixCommonArgs::MixCommonArgs(const string & programName) : programName(programName) { - mkFlag('v', "verbose", "increase verbosity level", []() { - verbosity = (Verbosity) (verbosity + 1); - }); + mkFlag() + .longName("verbose") + .shortName('v') + .description("increase verbosity level") + .handler([]() { verbosity = (Verbosity) (verbosity + 1); }); - mkFlag(0, "quiet", "decrease verbosity level", []() { - verbosity = verbosity > lvlError ? (Verbosity) (verbosity - 1) : lvlError; - }); + mkFlag() + .longName("quiet") + .description("decrease verbosity level") + .handler([]() { verbosity = verbosity > lvlError ? (Verbosity) (verbosity - 1) : lvlError; }); - mkFlag(0, "debug", "enable debug output", []() { - verbosity = lvlDebug; - }); + mkFlag() + .longName("debug") + .description("enable debug output") + .handler([]() { verbosity = lvlDebug; }); mkFlag() .longName("option") .labels({"name", "value"}) .description("set a Nix configuration option (overriding nix.conf)") .arity(2) - .handler([](Strings ss) { - auto name = ss.front(); ss.pop_front(); - auto value = ss.front(); + .handler([](std::vector<std::string> ss) { try { - settings.set(name, value); + settings.set(ss[0], ss[1]); } catch (UsageError & e) { warn(e.what()); } |