about summary refs log tree commit diff
path: root/src/nix/main.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-10-24T10·45+0200
committerEelco Dolstra <edolstra@gmail.com>2017-10-24T10·58+0200
commit0d59f1ca49c9f7f3b2edaadcf590360ec66a6257 (patch)
treea03d53d84fb61eb354e2634705d8a076f0c1c76d /src/nix/main.cc
parent25f32625e2f2a3a1e1b3a3811da82f21c3a3b880 (diff)
nix: Respect -I, --arg, --argstr
Also, random cleanup to argument handling.
Diffstat (limited to 'src/nix/main.cc')
-rw-r--r--src/nix/main.cc36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/nix/main.cc b/src/nix/main.cc
index ec9b58b20fe8..060402cd08d5 100644
--- a/src/nix/main.cc
+++ b/src/nix/main.cc
@@ -20,19 +20,29 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
 {
     NixArgs() : MultiCommand(*RegisterCommand::commands), MixCommonArgs("nix")
     {
-        mkFlag('h', "help", "show usage information", [&]() { showHelpAndExit(); });
-
-        mkFlag(0, "help-config", "show configuration options", [=]() {
-            std::cout << "The following configuration options are available:\n\n";
-            Table2 tbl;
-            for (const auto & s : settings._getSettings())
-                if (!s.second.isAlias)
-                    tbl.emplace_back(s.first, s.second.setting->description);
-            printTable(std::cout, tbl);
-            throw Exit();
-        });
-
-        mkFlag(0, "version", "show version information", std::bind(printVersion, programName));
+        mkFlag()
+            .longName("help")
+            .shortName('h')
+            .description("show usage information")
+            .handler([&]() { showHelpAndExit(); });
+
+        mkFlag()
+            .longName("help-config")
+            .description("show configuration options")
+            .handler([&]() {
+                std::cout << "The following configuration options are available:\n\n";
+                Table2 tbl;
+                for (const auto & s : settings._getSettings())
+                    if (!s.second.isAlias)
+                        tbl.emplace_back(s.first, s.second.setting->description);
+                printTable(std::cout, tbl);
+                throw Exit();
+            });
+
+        mkFlag()
+            .longName("version")
+            .description("show version information")
+            .handler([&]() { printVersion(programName); });
 
         std::string cat = "config";
         settings.convertToArgs(*this, cat);