1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 14:51:16 +02:00

Merge pull request #12972 from NixOS/mergify/bp/2.28-maintenance/pr-12967

Add trailing commas on addFlag incantations (backport #12967)
This commit is contained in:
mergify[bot] 2025-04-07 23:56:11 +00:00 committed by GitHub
commit a7f078aa84
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 67 additions and 65 deletions

View file

@ -237,12 +237,13 @@ void StorePathCommand::run(ref<Store> store, StorePaths && storePaths)
MixProfile::MixProfile() MixProfile::MixProfile()
{ {
addFlag( addFlag({
{.longName = "profile", .longName = "profile",
.description = "The profile to operate on.", .description = "The profile to operate on.",
.labels = {"path"}, .labels = {"path"},
.handler = {&profile}, .handler = {&profile},
.completer = completePath}); .completer = completePath,
});
} }
void MixProfile::updateProfile(const StorePath & storePath) void MixProfile::updateProfile(const StorePath & storePath)

View file

@ -63,7 +63,7 @@ MixEvalArgs::MixEvalArgs()
.description = "Pass the value *expr* as the argument *name* to Nix functions.", .description = "Pass the value *expr* as the argument *name* to Nix functions.",
.category = category, .category = category,
.labels = {"name", "expr"}, .labels = {"name", "expr"},
.handler = {[&](std::string name, std::string expr) { autoArgs.insert_or_assign(name, AutoArg{AutoArgExpr{expr}}); }} .handler = {[&](std::string name, std::string expr) { autoArgs.insert_or_assign(name, AutoArg{AutoArgExpr{expr}}); }},
}); });
addFlag({ addFlag({
@ -80,7 +80,7 @@ MixEvalArgs::MixEvalArgs()
.category = category, .category = category,
.labels = {"name", "path"}, .labels = {"name", "path"},
.handler = {[&](std::string name, std::string path) { autoArgs.insert_or_assign(name, AutoArg{AutoArgFile{path}}); }}, .handler = {[&](std::string name, std::string path) { autoArgs.insert_or_assign(name, AutoArg{AutoArgFile{path}}); }},
.completer = completePath .completer = completePath,
}); });
addFlag({ addFlag({
@ -105,7 +105,7 @@ MixEvalArgs::MixEvalArgs()
.labels = {"path"}, .labels = {"path"},
.handler = {[&](std::string s) { .handler = {[&](std::string s) {
lookupPath.elements.emplace_back(LookupPath::Elem::parse(s)); lookupPath.elements.emplace_back(LookupPath::Elem::parse(s));
}} }},
}); });
addFlag({ addFlag({
@ -131,7 +131,7 @@ MixEvalArgs::MixEvalArgs()
}}, }},
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) { .completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
completeFlakeRef(completions, openStore(), prefix); completeFlakeRef(completions, openStore(), prefix);
}} }},
}); });
addFlag({ addFlag({

View file

@ -64,21 +64,21 @@ MixFlakeOptions::MixFlakeOptions()
.handler = {[&]() { .handler = {[&]() {
lockFlags.recreateLockFile = true; lockFlags.recreateLockFile = true;
warn("'--recreate-lock-file' is deprecated and will be removed in a future version; use 'nix flake update' instead."); warn("'--recreate-lock-file' is deprecated and will be removed in a future version; use 'nix flake update' instead.");
}} }},
}); });
addFlag({ addFlag({
.longName = "no-update-lock-file", .longName = "no-update-lock-file",
.description = "Do not allow any updates to the flake's lock file.", .description = "Do not allow any updates to the flake's lock file.",
.category = category, .category = category,
.handler = {&lockFlags.updateLockFile, false} .handler = {&lockFlags.updateLockFile, false},
}); });
addFlag({ addFlag({
.longName = "no-write-lock-file", .longName = "no-write-lock-file",
.description = "Do not write the flake's newly generated lock file.", .description = "Do not write the flake's newly generated lock file.",
.category = category, .category = category,
.handler = {&lockFlags.writeLockFile, false} .handler = {&lockFlags.writeLockFile, false},
}); });
addFlag({ addFlag({
@ -94,14 +94,14 @@ MixFlakeOptions::MixFlakeOptions()
.handler = {[&]() { .handler = {[&]() {
lockFlags.useRegistries = false; lockFlags.useRegistries = false;
warn("'--no-registries' is deprecated; use '--no-use-registries'"); warn("'--no-registries' is deprecated; use '--no-use-registries'");
}} }},
}); });
addFlag({ addFlag({
.longName = "commit-lock-file", .longName = "commit-lock-file",
.description = "Commit changes to the flake's lock file.", .description = "Commit changes to the flake's lock file.",
.category = category, .category = category,
.handler = {&lockFlags.commitLockFile, true} .handler = {&lockFlags.commitLockFile, true},
}); });
addFlag({ addFlag({
@ -121,7 +121,7 @@ MixFlakeOptions::MixFlakeOptions()
}}, }},
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) { .completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
completeFlakeInputAttrPath(completions, getEvalState(), getFlakeRefsForCompletion(), prefix); completeFlakeInputAttrPath(completions, getEvalState(), getFlakeRefsForCompletion(), prefix);
}} }},
}); });
addFlag({ addFlag({
@ -141,7 +141,7 @@ MixFlakeOptions::MixFlakeOptions()
} else if (n == 1) { } else if (n == 1) {
completeFlakeRef(completions, getEvalState()->store, prefix); completeFlakeRef(completions, getEvalState()->store, prefix);
} }
}} }},
}); });
addFlag({ addFlag({
@ -152,7 +152,7 @@ MixFlakeOptions::MixFlakeOptions()
.handler = {[&](std::string lockFilePath) { .handler = {[&](std::string lockFilePath) {
lockFlags.referenceLockFilePath = {getFSSourceAccessor(), CanonPath(absPath(lockFilePath))}; lockFlags.referenceLockFilePath = {getFSSourceAccessor(), CanonPath(absPath(lockFilePath))};
}}, }},
.completer = completePath .completer = completePath,
}); });
addFlag({ addFlag({
@ -163,7 +163,7 @@ MixFlakeOptions::MixFlakeOptions()
.handler = {[&](std::string lockFilePath) { .handler = {[&](std::string lockFilePath) {
lockFlags.outputLockFilePath = lockFilePath; lockFlags.outputLockFilePath = lockFilePath;
}}, }},
.completer = completePath .completer = completePath,
}); });
addFlag({ addFlag({
@ -190,7 +190,7 @@ MixFlakeOptions::MixFlakeOptions()
}}, }},
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) { .completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
completeFlakeRef(completions, getEvalState()->store, prefix); completeFlakeRef(completions, getEvalState()->store, prefix);
}} }},
}); });
} }
@ -206,7 +206,7 @@ SourceExprCommand::SourceExprCommand()
.category = installablesCategory, .category = installablesCategory,
.labels = {"file"}, .labels = {"file"},
.handler = {&file}, .handler = {&file},
.completer = completePath .completer = completePath,
}); });
addFlag({ addFlag({
@ -214,7 +214,7 @@ SourceExprCommand::SourceExprCommand()
.description = "Interpret [*installables*](@docroot@/command-ref/new-cli/nix.md#installables) as attribute paths relative to the Nix expression *expr*.", .description = "Interpret [*installables*](@docroot@/command-ref/new-cli/nix.md#installables) as attribute paths relative to the Nix expression *expr*.",
.category = installablesCategory, .category = installablesCategory,
.labels = {"expr"}, .labels = {"expr"},
.handler = {&expr} .handler = {&expr},
}); });
} }
@ -834,7 +834,7 @@ RawInstallablesCommand::RawInstallablesCommand()
addFlag({ addFlag({
.longName = "stdin", .longName = "stdin",
.description = "Read installables from the standard input. No default installable applied.", .description = "Read installables from the standard input. No default installable applied.",
.handler = {&readFromStdIn, true} .handler = {&readFromStdIn, true},
}); });
expectArgs({ expectArgs({

View file

@ -57,7 +57,7 @@ MixCommonArgs::MixCommonArgs(const std::string & programName)
if (hasPrefix(s.first, prefix)) if (hasPrefix(s.first, prefix))
completions.add(s.first, fmt("Set the `%s` setting.", s.first)); completions.add(s.first, fmt("Set the `%s` setting.", s.first));
} }
} },
}); });
addFlag({ addFlag({
@ -75,7 +75,7 @@ MixCommonArgs::MixCommonArgs(const std::string & programName)
.labels = Strings{"jobs"}, .labels = Strings{"jobs"},
.handler = {[=](std::string s) { .handler = {[=](std::string s) {
settings.set("max-jobs", s); settings.set("max-jobs", s);
}} }},
}); });
std::string cat = "Options to override configuration settings"; std::string cat = "Options to override configuration settings";

View file

@ -231,7 +231,7 @@ LegacyArgs::LegacyArgs(const std::string & programName,
.handler = {[=](std::string s) { .handler = {[=](std::string s) {
auto n = string2IntWithUnitPrefix<uint64_t>(s); auto n = string2IntWithUnitPrefix<uint64_t>(s);
settings.set(dest, std::to_string(n)); settings.set(dest, std::to_string(n));
}} }},
}); });
}; };

View file

@ -278,21 +278,21 @@ template<> void BaseSetting<SandboxMode>::convertToArg(Args & args, const std::s
.aliases = aliases, .aliases = aliases,
.description = "Enable sandboxing.", .description = "Enable sandboxing.",
.category = category, .category = category,
.handler = {[this]() { override(smEnabled); }} .handler = {[this]() { override(smEnabled); }},
}); });
args.addFlag({ args.addFlag({
.longName = "no-" + name, .longName = "no-" + name,
.aliases = aliases, .aliases = aliases,
.description = "Disable sandboxing.", .description = "Disable sandboxing.",
.category = category, .category = category,
.handler = {[this]() { override(smDisabled); }} .handler = {[this]() { override(smDisabled); }},
}); });
args.addFlag({ args.addFlag({
.longName = "relaxed-" + name, .longName = "relaxed-" + name,
.aliases = aliases, .aliases = aliases,
.description = "Enable sandboxing, but allow builds to disable it.", .description = "Enable sandboxing, but allow builds to disable it.",
.category = category, .category = category,
.handler = {[this]() { override(smRelaxed); }} .handler = {[this]() { override(smRelaxed); }},
}); });
} }

View file

@ -55,7 +55,7 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixJSON, MixProfile
.description = "Use *path* as prefix for the symlinks to the build results. It defaults to `result`.", .description = "Use *path* as prefix for the symlinks to the build results. It defaults to `result`.",
.labels = {"path"}, .labels = {"path"},
.handler = {&outLink}, .handler = {&outLink},
.completer = completePath .completer = completePath,
}); });
addFlag({ addFlag({

View file

@ -24,7 +24,7 @@ struct CmdBundle : InstallableValueCommand
.handler = {&bundler}, .handler = {&bundler},
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) { .completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
completeFlakeRef(completions, getStore(), prefix); completeFlakeRef(completions, getStore(), prefix);
}} }},
}); });
addFlag({ addFlag({
@ -33,7 +33,7 @@ struct CmdBundle : InstallableValueCommand
.description = "Override the name of the symlink to the build result. It defaults to the base name of the app.", .description = "Override the name of the symlink to the build result. It defaults to the base name of the app.",
.labels = {"path"}, .labels = {"path"},
.handler = {&outLink}, .handler = {&outLink},
.completer = completePath .completer = completePath,
}); });
} }

View file

@ -21,7 +21,7 @@ struct CmdCopy : virtual CopyCommand, virtual BuiltPathsCommand, MixProfile
.description = "Create symlinks prefixed with *path* to the top-level store paths fetched from the source store.", .description = "Create symlinks prefixed with *path* to the top-level store paths fetched from the source store.",
.labels = {"path"}, .labels = {"path"},
.handler = {&outLink}, .handler = {&outLink},
.completer = completePath .completer = completePath,
}); });
addFlag({ addFlag({

View file

@ -21,7 +21,7 @@ struct CmdShowDerivation : InstallablesCommand
.longName = "recursive", .longName = "recursive",
.shortName = 'r', .shortName = 'r',
.description = "Include the dependencies of the specified derivations.", .description = "Include the dependencies of the specified derivations.",
.handler = {&recursive, true} .handler = {&recursive, true},
}); });
} }

View file

@ -334,7 +334,7 @@ struct Common : InstallableCommand, MixProfile
.labels = {"installable", "outputs-dir"}, .labels = {"installable", "outputs-dir"},
.handler = {[&](std::string installable, std::string outputsDir) { .handler = {[&](std::string installable, std::string outputsDir) {
redirects.push_back({installable, outputsDir}); redirects.push_back({installable, outputsDir});
}} }},
}); });
} }
@ -524,7 +524,7 @@ struct CmdDevelop : Common, MixEnvironment
.handler = {[&](std::vector<std::string> ss) { .handler = {[&](std::vector<std::string> ss) {
if (ss.empty()) throw UsageError("--command requires at least one argument"); if (ss.empty()) throw UsageError("--command requires at least one argument");
command = ss; command = ss;
}} }},
}); });
addFlag({ addFlag({

View file

@ -38,16 +38,17 @@ struct CmdShell : InstallablesCommand, MixEnvironment
CmdShell() CmdShell()
{ {
addFlag( addFlag({
{.longName = "command", .longName = "command",
.shortName = 'c', .shortName = 'c',
.description = "Command and arguments to be executed, defaulting to `$SHELL`", .description = "Command and arguments to be executed, defaulting to `$SHELL`",
.labels = {"command", "args"}, .labels = {"command", "args"},
.handler = {[&](std::vector<std::string> ss) { .handler = {[&](std::vector<std::string> ss) {
if (ss.empty()) if (ss.empty())
throw UsageError("--command requires at least one argument"); throw UsageError("--command requires at least one argument");
command = ss; command = ss;
}}}); }},
});
} }
std::string description() override std::string description() override

View file

@ -90,7 +90,7 @@ public:
.handler={&flakeUrl}, .handler={&flakeUrl},
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) { .completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
completeFlakeRef(completions, getStore(), prefix); completeFlakeRef(completions, getStore(), prefix);
}} }},
}); });
expectArgs({ expectArgs({
.label="inputs", .label="inputs",
@ -111,7 +111,7 @@ public:
}}, }},
.completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) { .completer = {[&](AddCompletions & completions, size_t, std::string_view prefix) {
completeFlakeInputAttrPath(completions, getEvalState(), getFlakeRefsForCompletion(), prefix); completeFlakeInputAttrPath(completions, getEvalState(), getFlakeRefsForCompletion(), prefix);
}} }},
}); });
/* Remove flags that don't make sense. */ /* Remove flags that don't make sense. */
@ -336,12 +336,12 @@ struct CmdFlakeCheck : FlakeCommand
addFlag({ addFlag({
.longName = "no-build", .longName = "no-build",
.description = "Do not build checks.", .description = "Do not build checks.",
.handler = {&build, false} .handler = {&build, false},
}); });
addFlag({ addFlag({
.longName = "all-systems", .longName = "all-systems",
.description = "Check the outputs for all systems.", .description = "Check the outputs for all systems.",
.handler = {&checkAllSystems, true} .handler = {&checkAllSystems, true},
}); });
} }
@ -874,7 +874,7 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
defaultTemplateAttrPathsPrefixes, defaultTemplateAttrPathsPrefixes,
defaultTemplateAttrPaths, defaultTemplateAttrPaths,
prefix); prefix);
}} }},
}); });
} }
@ -1034,7 +1034,7 @@ struct CmdFlakeClone : FlakeCommand
.shortName = 'f', .shortName = 'f',
.description = "Clone the flake to path *dest*.", .description = "Clone the flake to path *dest*.",
.labels = {"path"}, .labels = {"path"},
.handler = {&destDir} .handler = {&destDir},
}); });
} }
@ -1057,7 +1057,7 @@ struct CmdFlakeArchive : FlakeCommand, MixJSON, MixDryRun
.longName = "to", .longName = "to",
.description = "URI of the destination Nix store", .description = "URI of the destination Nix store",
.labels = {"store-uri"}, .labels = {"store-uri"},
.handler = {&dstUri} .handler = {&dstUri},
}); });
} }
@ -1137,12 +1137,12 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
addFlag({ addFlag({
.longName = "legacy", .longName = "legacy",
.description = "Show the contents of the `legacyPackages` output.", .description = "Show the contents of the `legacyPackages` output.",
.handler = {&showLegacy, true} .handler = {&showLegacy, true},
}); });
addFlag({ addFlag({
.longName = "all-systems", .longName = "all-systems",
.description = "Show the contents of outputs for all systems.", .description = "Show the contents of outputs for all systems.",
.handler = {&showAllSystems, true} .handler = {&showAllSystems, true},
}); });
} }
@ -1443,7 +1443,7 @@ struct CmdFlakePrefetch : FlakeCommand, MixJSON
.description = "Create symlink named *path* to the resulting store path.", .description = "Create symlink named *path* to the resulting store path.",
.labels = {"path"}, .labels = {"path"},
.handler = {&outLink}, .handler = {&outLink},
.completer = completePath .completer = completePath,
}); });
} }

View file

@ -275,7 +275,7 @@ struct CmdStorePrefetchFile : StoreCommand, MixJSON
.longName = "name", .longName = "name",
.description = "Override the name component of the resulting store path. It defaults to the base name of *url*.", .description = "Override the name component of the resulting store path. It defaults to the base name of *url*.",
.labels = {"name"}, .labels = {"name"},
.handler = {&name} .handler = {&name},
}); });
addFlag({ addFlag({
@ -284,7 +284,7 @@ struct CmdStorePrefetchFile : StoreCommand, MixJSON
.labels = {"hash"}, .labels = {"hash"},
.handler = {[&](std::string s) { .handler = {[&](std::string s) {
expectedHash = Hash::parseAny(s, hashAlgo); expectedHash = Hash::parseAny(s, hashAlgo);
}} }},
}); });
addFlag(flag::hashAlgo("hash-type", &hashAlgo)); addFlag(flag::hashAlgo("hash-type", &hashAlgo));

View file

@ -104,7 +104,7 @@ struct CmdSign : StorePathsCommand
.description = "File containing the secret signing key.", .description = "File containing the secret signing key.",
.labels = {"file"}, .labels = {"file"},
.handler = {&secretKeyFile}, .handler = {&secretKeyFile},
.completer = completePath .completer = completePath,
}); });
} }

View file

@ -16,7 +16,7 @@ struct CmdStoreDelete : StorePathsCommand
addFlag({ addFlag({
.longName = "ignore-liveness", .longName = "ignore-liveness",
.description = "Do not check whether the paths are reachable from a root.", .description = "Do not check whether the paths are reachable from a root.",
.handler = {&options.ignoreLiveness, true} .handler = {&options.ignoreLiveness, true},
}); });
} }

View file

@ -17,7 +17,7 @@ struct CmdStoreGC : StoreCommand, MixDryRun
.longName = "max", .longName = "max",
.description = "Stop after freeing *n* bytes of disk space.", .description = "Stop after freeing *n* bytes of disk space.",
.labels = {"n"}, .labels = {"n"},
.handler = {&options.maxFreed} .handler = {&options.maxFreed},
}); });
} }

View file

@ -23,14 +23,14 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand
.shortName = 'p', .shortName = 'p',
.description = "The path to the Nix profile to upgrade.", .description = "The path to the Nix profile to upgrade.",
.labels = {"profile-dir"}, .labels = {"profile-dir"},
.handler = {&profileDir} .handler = {&profileDir},
}); });
addFlag({ addFlag({
.longName = "nix-store-paths-url", .longName = "nix-store-paths-url",
.description = "The URL of the file that contains the store paths of the latest Nix release.", .description = "The URL of the file that contains the store paths of the latest Nix release.",
.labels = {"url"}, .labels = {"url"},
.handler = {&(std::string&) settings.upgradeNixStorePathUrl} .handler = {&(std::string&) settings.upgradeNixStorePathUrl},
}); });
} }

View file

@ -37,7 +37,7 @@ struct CmdVerify : StorePathsCommand
.shortName = 's', .shortName = 's',
.description = "Use signatures from the specified store.", .description = "Use signatures from the specified store.",
.labels = {"store-uri"}, .labels = {"store-uri"},
.handler = {[&](std::string s) { substituterUris.push_back(s); }} .handler = {[&](std::string s) { substituterUris.push_back(s); }},
}); });
addFlag({ addFlag({
@ -45,7 +45,7 @@ struct CmdVerify : StorePathsCommand
.shortName = 'n', .shortName = 'n',
.description = "Require that each path is signed by at least *n* different keys.", .description = "Require that each path is signed by at least *n* different keys.",
.labels = {"n"}, .labels = {"n"},
.handler = {&sigsNeeded} .handler = {&sigsNeeded},
}); });
} }