Remove mkFlag()
This commit is contained in:
parent
f15f0b8e83
commit
8e758d402b
|
@ -229,11 +229,17 @@ LegacyArgs::LegacyArgs(const std::string & programName,
|
||||||
intSettingAlias(0, "max-silent-time", "Number of seconds of silence before a build is killed.", "max-silent-time");
|
intSettingAlias(0, "max-silent-time", "Number of seconds of silence before a build is killed.", "max-silent-time");
|
||||||
intSettingAlias(0, "timeout", "Number of seconds before a build is killed.", "timeout");
|
intSettingAlias(0, "timeout", "Number of seconds before a build is killed.", "timeout");
|
||||||
|
|
||||||
mkFlag(0, "readonly-mode", "Do not write to the Nix store.",
|
addFlag({
|
||||||
&settings.readOnlyMode);
|
.longName = "readonly-mode",
|
||||||
|
.description = "Do not write to the Nix store.",
|
||||||
|
.handler = {&settings.readOnlyMode, true},
|
||||||
|
});
|
||||||
|
|
||||||
mkFlag(0, "no-gc-warning", "Disable warnings about not using `--add-root`.",
|
addFlag({
|
||||||
&gcWarning, false);
|
.longName = "no-gc-warning",
|
||||||
|
.description = "Disable warnings about not using `--add-root`.",
|
||||||
|
.handler = {&gcWarning, true},
|
||||||
|
});
|
||||||
|
|
||||||
addFlag({
|
addFlag({
|
||||||
.longName = "store",
|
.longName = "store",
|
||||||
|
|
|
@ -135,27 +135,6 @@ public:
|
||||||
|
|
||||||
void addFlag(Flag && flag);
|
void addFlag(Flag && flag);
|
||||||
|
|
||||||
/* Helper functions for constructing flags / positional
|
|
||||||
arguments. */
|
|
||||||
|
|
||||||
void mkFlag(char shortName, const std::string & name,
|
|
||||||
const std::string & description, bool * dest)
|
|
||||||
{
|
|
||||||
mkFlag(shortName, name, description, dest, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void mkFlag(char shortName, const std::string & longName, const std::string & description,
|
|
||||||
T * dest, const T & value)
|
|
||||||
{
|
|
||||||
addFlag({
|
|
||||||
.longName = longName,
|
|
||||||
.shortName = shortName,
|
|
||||||
.description = description,
|
|
||||||
.handler = {[=]() { *dest = value; }}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void expectArgs(ExpectedArg && arg)
|
void expectArgs(ExpectedArg && arg)
|
||||||
{
|
{
|
||||||
expectedArgs.emplace_back(std::move(arg));
|
expectedArgs.emplace_back(std::move(arg));
|
||||||
|
|
|
@ -18,7 +18,11 @@ struct CmdEval : MixJSON, InstallableCommand
|
||||||
|
|
||||||
CmdEval()
|
CmdEval()
|
||||||
{
|
{
|
||||||
mkFlag(0, "raw", "Print strings without quotes or escaping.", &raw);
|
addFlag({
|
||||||
|
.longName = "raw",
|
||||||
|
.description = "Print strings without quotes or escaping.",
|
||||||
|
.handler = {&raw, true},
|
||||||
|
});
|
||||||
|
|
||||||
addFlag({
|
addFlag({
|
||||||
.longName = "apply",
|
.longName = "apply",
|
||||||
|
|
|
@ -19,18 +19,41 @@ struct CmdHashBase : Command
|
||||||
|
|
||||||
CmdHashBase(FileIngestionMethod mode) : mode(mode)
|
CmdHashBase(FileIngestionMethod mode) : mode(mode)
|
||||||
{
|
{
|
||||||
mkFlag(0, "sri", "Print the hash in SRI format.", &base, SRI);
|
addFlag({
|
||||||
mkFlag(0, "base64", "Print the hash in base-64 format.", &base, Base64);
|
.longName = "sri",
|
||||||
mkFlag(0, "base32", "Print the hash in base-32 (Nix-specific) format.", &base, Base32);
|
.description = "Print the hash in SRI format.",
|
||||||
mkFlag(0, "base16", "Print the hash in base-16 format.", &base, Base16);
|
.handler = {&base, SRI},
|
||||||
|
});
|
||||||
|
|
||||||
|
addFlag({
|
||||||
|
.longName = "base64",
|
||||||
|
.description = "Print the hash in base-64 format.",
|
||||||
|
.handler = {&base, Base64},
|
||||||
|
});
|
||||||
|
|
||||||
|
addFlag({
|
||||||
|
.longName = "base32",
|
||||||
|
.description = "Print the hash in base-32 (Nix-specific) format.",
|
||||||
|
.handler = {&base, Base32},
|
||||||
|
});
|
||||||
|
|
||||||
|
addFlag({
|
||||||
|
.longName = "base16",
|
||||||
|
.description = "Print the hash in base-16 format.",
|
||||||
|
.handler = {&base, Base16},
|
||||||
|
});
|
||||||
|
|
||||||
addFlag(Flag::mkHashTypeFlag("type", &ht));
|
addFlag(Flag::mkHashTypeFlag("type", &ht));
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
mkFlag()
|
addFlag({
|
||||||
.longName("modulo")
|
.longName = "modulo",
|
||||||
.description("Compute the hash modulo specified the string.")
|
.description = "Compute the hash modulo the specified string.",
|
||||||
.labels({"modulus"})
|
.labels = {"modulus"},
|
||||||
.dest(&modulus);
|
.handler = {&modulus},
|
||||||
#endif
|
});
|
||||||
|
#endif\
|
||||||
|
|
||||||
expectArgs({
|
expectArgs({
|
||||||
.label = "paths",
|
.label = "paths",
|
||||||
.handler = {&paths},
|
.handler = {&paths},
|
||||||
|
|
|
@ -17,9 +17,26 @@ struct MixLs : virtual Args, MixJSON
|
||||||
|
|
||||||
MixLs()
|
MixLs()
|
||||||
{
|
{
|
||||||
mkFlag('R', "recursive", "List subdirectories recursively.", &recursive);
|
addFlag({
|
||||||
mkFlag('l', "long", "Show detailed file information.", &verbose);
|
.longName = "recursive",
|
||||||
mkFlag('d', "directory", "Show directories rather than their contents.", &showDirectory);
|
.shortName = 'R',
|
||||||
|
.description = "List subdirectories recursively.",
|
||||||
|
.handler = {&recursive, true},
|
||||||
|
});
|
||||||
|
|
||||||
|
addFlag({
|
||||||
|
.longName = "long",
|
||||||
|
.shortName = 'l',
|
||||||
|
.description = "Show detailed file information.",
|
||||||
|
.handler = {&verbose, true},
|
||||||
|
});
|
||||||
|
|
||||||
|
addFlag({
|
||||||
|
.longName = "directory",
|
||||||
|
.shortName = 'd',
|
||||||
|
.description = "Show directories rather than their contents.",
|
||||||
|
.handler = {&showDirectory, true},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void listText(ref<FSAccessor> accessor)
|
void listText(ref<FSAccessor> accessor)
|
||||||
|
|
|
@ -18,10 +18,32 @@ struct CmdPathInfo : StorePathsCommand, MixJSON
|
||||||
|
|
||||||
CmdPathInfo()
|
CmdPathInfo()
|
||||||
{
|
{
|
||||||
mkFlag('s', "size", "Print the size of the NAR serialisation of each path.", &showSize);
|
addFlag({
|
||||||
mkFlag('S', "closure-size", "Print the sum of the sizes of the NAR serialisations of the closure of each path.", &showClosureSize);
|
.longName = "size",
|
||||||
mkFlag('h', "human-readable", "With `-s` and `-S`, print sizes in a human-friendly format such as `5.67G`.", &humanReadable);
|
.shortName = 's',
|
||||||
mkFlag(0, "sigs", "Show signatures.", &showSigs);
|
.description = "Print the size of the NAR serialisation of each path.",
|
||||||
|
.handler = {&showSize, true},
|
||||||
|
});
|
||||||
|
|
||||||
|
addFlag({
|
||||||
|
.longName = "closure-size",
|
||||||
|
.shortName = 'S',
|
||||||
|
.description = "Print the sum of the sizes of the NAR serialisations of the closure of each path.",
|
||||||
|
.handler = {&showClosureSize, true},
|
||||||
|
});
|
||||||
|
|
||||||
|
addFlag({
|
||||||
|
.longName = "human-readable",
|
||||||
|
.shortName = 'h',
|
||||||
|
.description = "With `-s` and `-S`, print sizes in a human-friendly format such as `5.67G`.",
|
||||||
|
.handler = {&humanReadable, true},
|
||||||
|
});
|
||||||
|
|
||||||
|
addFlag({
|
||||||
|
.longName = "sigs",
|
||||||
|
.description = "Show signatures.",
|
||||||
|
.handler = {&showSigs, true},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string description() override
|
std::string description() override
|
||||||
|
|
|
@ -18,8 +18,17 @@ struct CmdVerify : StorePathsCommand
|
||||||
|
|
||||||
CmdVerify()
|
CmdVerify()
|
||||||
{
|
{
|
||||||
mkFlag(0, "no-contents", "Do not verify the contents of each store path.", &noContents);
|
addFlag({
|
||||||
mkFlag(0, "no-trust", "Do not verify whether each store path is trusted.", &noTrust);
|
.longName = "no-contents",
|
||||||
|
.description = "Do not verify the contents of each store path.",
|
||||||
|
.handler = {&noContents, true},
|
||||||
|
});
|
||||||
|
|
||||||
|
addFlag({
|
||||||
|
.longName = "no-trust",
|
||||||
|
.description = "Do not verify whether each store path is trusted.",
|
||||||
|
.handler = {&noTrust, true},
|
||||||
|
});
|
||||||
|
|
||||||
addFlag({
|
addFlag({
|
||||||
.longName = "substituter",
|
.longName = "substituter",
|
||||||
|
|
Loading…
Reference in a new issue