mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 16:26:18 +02:00
Fix to-base --type handler to correctly set std::optional flag
Now that we have a separate flag function, also describe why it is optional.
This commit is contained in:
parent
c502119fd3
commit
c664e68b87
3 changed files with 14 additions and 1 deletions
|
@ -166,6 +166,18 @@ Args::Flag Args::Flag::mkHashTypeFlag(std::string && longName, HashType * ht)
|
|||
};
|
||||
}
|
||||
|
||||
Args::Flag Args::Flag::mkHashTypeOptFlag(std::string && longName, std::optional<HashType> * oht)
|
||||
{
|
||||
return Flag {
|
||||
.longName = std::move(longName),
|
||||
.description = "hash algorithm ('md5', 'sha1', 'sha256', or 'sha512'). Optional as can also be gotten from SRI hash itself.",
|
||||
.labels = {"hash-algo"},
|
||||
.handler = {[oht](std::string s) {
|
||||
*oht = std::optional<HashType> { parseHashType(s) };
|
||||
}}
|
||||
};
|
||||
}
|
||||
|
||||
Strings argvToStrings(int argc, char * * argv)
|
||||
{
|
||||
Strings args;
|
||||
|
|
|
@ -85,6 +85,7 @@ protected:
|
|||
Handler handler;
|
||||
|
||||
static Flag mkHashTypeFlag(std::string && longName, HashType * ht);
|
||||
static Flag mkHashTypeOptFlag(std::string && longName, std::optional<HashType> * oht);
|
||||
};
|
||||
|
||||
std::map<std::string, Flag::ptr> longFlags;
|
||||
|
|
|
@ -84,7 +84,7 @@ struct CmdToBase : Command
|
|||
|
||||
CmdToBase(Base base) : base(base)
|
||||
{
|
||||
addFlag(Flag::mkHashTypeFlag("type", &*ht));
|
||||
addFlag(Flag::mkHashTypeOptFlag("type", &ht));
|
||||
expectArgs("strings", &args);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue