aboutsummaryrefslogtreecommitdiff
path: root/src/nix/main.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-05-04 22:40:19 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-05-04 22:40:19 +0200
commita721a0b1140bf489d645f5d85737acafc1c57c65 (patch)
treef4b7df80fccc95b46fd3e8419375b563b466cfa4 /src/nix/main.cc
parente9f10beed1a30fe80b315a9de4c4c2ab11527db8 (diff)
Flag: Use designated initializers
Diffstat (limited to 'src/nix/main.cc')
-rw-r--r--src/nix/main.cc68
1 files changed, 37 insertions, 31 deletions
diff --git a/src/nix/main.cc b/src/nix/main.cc
index 2c64c7476..57b8bed9f 100644
--- a/src/nix/main.cc
+++ b/src/nix/main.cc
@@ -59,15 +59,16 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
NixArgs() : MultiCommand(*RegisterCommand::commands), MixCommonArgs("nix")
{
- mkFlag()
- .longName("help")
- .description("show usage information")
- .handler([&]() { showHelpAndExit(); });
-
- mkFlag()
- .longName("help-config")
- .description("show configuration options")
- .handler([&]() {
+ addFlag({
+ .longName = "help",
+ .description = "show usage information",
+ .handler = {[&]() { showHelpAndExit(); }},
+ });
+
+ addFlag({
+ .longName = "help-config",
+ .description = "show configuration options",
+ .handler = {[&]() {
std::cout << "The following configuration options are available:\n\n";
Table2 tbl;
std::map<std::string, Config::SettingInfo> settings;
@@ -76,28 +77,33 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
tbl.emplace_back(s.first, s.second.description);
printTable(std::cout, tbl);
throw Exit();
- });
-
- mkFlag()
- .longName("print-build-logs")
- .shortName('L')
- .description("print full build logs on stderr")
- .set(&printBuildLogs, true);
-
- mkFlag()
- .longName("version")
- .description("show version information")
- .handler([&]() { printVersion(programName); });
-
- mkFlag()
- .longName("no-net")
- .description("disable substituters and consider all previously downloaded files up-to-date")
- .handler([&]() { useNet = false; });
-
- mkFlag()
- .longName("refresh")
- .description("consider all previously downloaded files out-of-date")
- .handler([&]() { refresh = true; });
+ }},
+ });
+
+ addFlag({
+ .longName = "print-build-logs",
+ .shortName = 'L',
+ .description = "print full build logs on stderr",
+ .handler = {&printBuildLogs, true},
+ });
+
+ addFlag({
+ .longName = "version",
+ .description = "show version information",
+ .handler = {[&]() { printVersion(programName); }},
+ });
+
+ addFlag({
+ .longName = "no-net",
+ .description = "disable substituters and consider all previously downloaded files up-to-date",
+ .handler = {[&]() { useNet = false; }},
+ });
+
+ addFlag({
+ .longName = "refresh",
+ .description = "consider all previously downloaded files out-of-date",
+ .handler = {[&]() { refresh = true; }},
+ });
}
void printFlags(std::ostream & out) override