forked from lix-project/lix
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, "timeout", "Number of seconds before a build is killed.", "timeout");
|
||||
|
||||
mkFlag(0, "readonly-mode", "Do not write to the Nix store.",
|
||||
&settings.readOnlyMode);
|
||||
addFlag({
|
||||
.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`.",
|
||||
&gcWarning, false);
|
||||
addFlag({
|
||||
.longName = "no-gc-warning",
|
||||
.description = "Disable warnings about not using `--add-root`.",
|
||||
.handler = {&gcWarning, true},
|
||||
});
|
||||
|
||||
addFlag({
|
||||
.longName = "store",
|
||||
|
|
|
@ -135,27 +135,6 @@ public:
|
|||
|
||||
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)
|
||||
{
|
||||
expectedArgs.emplace_back(std::move(arg));
|
||||
|
|
|
@ -18,7 +18,11 @@ struct CmdEval : MixJSON, InstallableCommand
|
|||
|
||||
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({
|
||||
.longName = "apply",
|
||||
|
|
|
@ -19,18 +19,41 @@ struct CmdHashBase : Command
|
|||
|
||||
CmdHashBase(FileIngestionMethod mode) : mode(mode)
|
||||
{
|
||||
mkFlag(0, "sri", "Print the hash in SRI format.", &base, SRI);
|
||||
mkFlag(0, "base64", "Print the hash in base-64 format.", &base, Base64);
|
||||
mkFlag(0, "base32", "Print the hash in base-32 (Nix-specific) format.", &base, Base32);
|
||||
mkFlag(0, "base16", "Print the hash in base-16 format.", &base, Base16);
|
||||
addFlag({
|
||||
.longName = "sri",
|
||||
.description = "Print the hash in SRI format.",
|
||||
.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));
|
||||
|
||||
#if 0
|
||||
mkFlag()
|
||||
.longName("modulo")
|
||||
.description("Compute the hash modulo specified the string.")
|
||||
.labels({"modulus"})
|
||||
.dest(&modulus);
|
||||
#endif
|
||||
addFlag({
|
||||
.longName = "modulo",
|
||||
.description = "Compute the hash modulo the specified string.",
|
||||
.labels = {"modulus"},
|
||||
.handler = {&modulus},
|
||||
});
|
||||
#endif\
|
||||
|
||||
expectArgs({
|
||||
.label = "paths",
|
||||
.handler = {&paths},
|
||||
|
|
|
@ -17,9 +17,26 @@ struct MixLs : virtual Args, MixJSON
|
|||
|
||||
MixLs()
|
||||
{
|
||||
mkFlag('R', "recursive", "List subdirectories recursively.", &recursive);
|
||||
mkFlag('l', "long", "Show detailed file information.", &verbose);
|
||||
mkFlag('d', "directory", "Show directories rather than their contents.", &showDirectory);
|
||||
addFlag({
|
||||
.longName = "recursive",
|
||||
.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)
|
||||
|
|
|
@ -18,10 +18,32 @@ struct CmdPathInfo : StorePathsCommand, MixJSON
|
|||
|
||||
CmdPathInfo()
|
||||
{
|
||||
mkFlag('s', "size", "Print the size of the NAR serialisation of each path.", &showSize);
|
||||
mkFlag('S', "closure-size", "Print the sum of the sizes of the NAR serialisations of the closure of each path.", &showClosureSize);
|
||||
mkFlag('h', "human-readable", "With `-s` and `-S`, print sizes in a human-friendly format such as `5.67G`.", &humanReadable);
|
||||
mkFlag(0, "sigs", "Show signatures.", &showSigs);
|
||||
addFlag({
|
||||
.longName = "size",
|
||||
.shortName = 's',
|
||||
.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
|
||||
|
|
|
@ -18,8 +18,17 @@ struct CmdVerify : StorePathsCommand
|
|||
|
||||
CmdVerify()
|
||||
{
|
||||
mkFlag(0, "no-contents", "Do not verify the contents of each store path.", &noContents);
|
||||
mkFlag(0, "no-trust", "Do not verify whether each store path is trusted.", &noTrust);
|
||||
addFlag({
|
||||
.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({
|
||||
.longName = "substituter",
|
||||
|
|
Loading…
Reference in a new issue