diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-02 23:30:38 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-03 04:44:24 +0000 |
commit | 3c78ac348c3a32fa6d78d3c56645901513c2e731 (patch) | |
tree | b4ff0079484b825f884eb98ff88655142d386f58 /src/libutil/args.cc | |
parent | fecff16a6e8bffce9a404b1508fec375e83ec01e (diff) | |
parent | 406dbb7fce32f7d80b02f560d91c956698b58d6e (diff) |
Merge remote-tracking branch 'obsidian/no-hash-type-unknown' into validPathInfo-ca-proper-datatype
Diffstat (limited to 'src/libutil/args.cc')
-rw-r--r-- | src/libutil/args.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libutil/args.cc b/src/libutil/args.cc index 4a3f5aae8..4fe9539e4 100644 --- a/src/libutil/args.cc +++ b/src/libutil/args.cc @@ -162,8 +162,18 @@ Args::Flag Args::Flag::mkHashTypeFlag(std::string && longName, HashType * ht) .labels = {"hash-algo"}, .handler = {[ht](std::string s) { *ht = parseHashType(s); - if (*ht == HashType::Unknown) - throw UsageError("unknown hash type '%1%'", s); + }} + }; +} + +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) }; }} }; } |