diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-02 18:25:32 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-02 18:25:32 +0000 |
commit | c664e68b87a3e9e41c4471276886da71793b2d85 (patch) | |
tree | 4588e89a54039765077433eb4406953b008e4872 /src/libutil/args.cc | |
parent | c502119fd3b9673e966d5c34ec42cbe18baa17b9 (diff) |
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.
Diffstat (limited to 'src/libutil/args.cc')
-rw-r--r-- | src/libutil/args.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libutil/args.cc b/src/libutil/args.cc index c4035ab85..4fe9539e4 100644 --- a/src/libutil/args.cc +++ b/src/libutil/args.cc @@ -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; |