aboutsummaryrefslogtreecommitdiff
path: root/src/libmain/common-args.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-17 03:52:01 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-17 03:52:01 +0000
commit21ef342172366cf66a5ff952da9ba1d825aec064 (patch)
tree3944c04a65b1f29f2cb162b806e04285eafed541 /src/libmain/common-args.cc
parentbcde5456cc3295061a0726881c3e441444dd6680 (diff)
parent29542865cee37ab22efe1bd142900b69f6c59f0d (diff)
Merge remote-tracking branch 'upstream/master' into derivation-header-include-order
Diffstat (limited to 'src/libmain/common-args.cc')
-rw-r--r--src/libmain/common-args.cc77
1 files changed, 45 insertions, 32 deletions
diff --git a/src/libmain/common-args.cc b/src/libmain/common-args.cc
index 9e1d7cee6..051668e53 100644
--- a/src/libmain/common-args.cc
+++ b/src/libmain/common-args.cc
@@ -1,48 +1,61 @@
#include "common-args.hh"
#include "globals.hh"
+#include "loggers.hh"
namespace nix {
MixCommonArgs::MixCommonArgs(const string & programName)
: programName(programName)
{
- mkFlag()
- .longName("verbose")
- .shortName('v')
- .description("increase verbosity level")
- .handler([]() { verbosity = (Verbosity) (verbosity + 1); });
-
- mkFlag()
- .longName("quiet")
- .description("decrease verbosity level")
- .handler([]() { verbosity = verbosity > lvlError ? (Verbosity) (verbosity - 1) : lvlError; });
-
- 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([](std::vector<std::string> ss) {
+ addFlag({
+ .longName = "verbose",
+ .shortName = 'v',
+ .description = "increase verbosity level",
+ .handler = {[]() { verbosity = (Verbosity) (verbosity + 1); }},
+ });
+
+ addFlag({
+ .longName = "quiet",
+ .description = "decrease verbosity level",
+ .handler = {[]() { verbosity = verbosity > lvlError ? (Verbosity) (verbosity - 1) : lvlError; }},
+ });
+
+ addFlag({
+ .longName = "debug",
+ .description = "enable debug output",
+ .handler = {[]() { verbosity = lvlDebug; }},
+ });
+
+ addFlag({
+ .longName = "option",
+ .description = "set a Nix configuration option (overriding nix.conf)",
+ .labels = {"name", "value"},
+ .handler = {[](std::string name, std::string value) {
try {
- globalConfig.set(ss[0], ss[1]);
+ globalConfig.set(name, value);
} catch (UsageError & e) {
warn(e.what());
}
- });
-
- mkFlag()
- .longName("max-jobs")
- .shortName('j')
- .label("jobs")
- .description("maximum number of parallel builds")
- .handler([=](std::string s) {
+ }},
+ });
+
+ addFlag({
+ .longName = "log-format",
+ .description = "format of log output; \"raw\", \"internal-json\", \"bar\" "
+ "or \"bar-with-logs\"",
+ .labels = {"format"},
+ .handler = {[](std::string format) { setLogFormat(format); }},
+ });
+
+ addFlag({
+ .longName = "max-jobs",
+ .shortName = 'j',
+ .description = "maximum number of parallel builds",
+ .labels = Strings{"jobs"},
+ .handler = {[=](std::string s) {
settings.set("max-jobs", s);
- });
+ }}
+ });
std::string cat = "config";
globalConfig.convertToArgs(*this, cat);