about summary refs log tree commit diff
path: root/src/libmain/common-args.cc
blob: 9a7a893138dee32e435d43c4b51157596989f37b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "common-args.hh"
#include "globals.hh"

namespace nix {

MixCommonArgs::MixCommonArgs(const string & programName)
    : programName(programName)
{
    mkFlag('v', "verbose", "increase verbosity level", []() {
        verbosity = (Verbosity) (verbosity + 1);
    });

    mkFlag(0, "quiet", "decrease verbosity level", []() {
        verbosity = verbosity > lvlError ? (Verbosity) (verbosity - 1) : lvlError;
    });

    mkFlag(0, "debug", "enable debug output", []() {
        verbosity = lvlDebug;
    });

    mkFlag(0, "option", {"name", "value"}, "set a Nix configuration option (overriding nix.conf)", 2,
        [](Strings ss) {
            auto name = ss.front(); ss.pop_front();
            auto value = ss.front();
            try {
                settings.set(name, value);
            } catch (UsageError & e) {
                warn(e.what());
            }
        });
}

}