From: Nathaniel Wesley Filardo Date: Tue, 15 Nov 2022 03:16:15 +0000 (+0000) Subject: Add :choices() to argparse options X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=a70cc3d943fc82453cbcb1b1ca673e90f6336f5e;p=csdb Add :choices() to argparse options Now that Debian has pulled in a sufficiently new lua-argparse (though only in testing). --- diff --git a/cdb b/cdb index 32540fd..e9fbb42 100755 --- a/cdb +++ b/cdb @@ -168,8 +168,10 @@ local function argparse_flag_inul(c) end local function argparse_for_db_filter(c) - c:option("--predicate"):default("in") - -- TODO: :choices({"in", "out"}) + c:option("--predicate -p"):default("in") + :choices({"in", "out"}) + :argname("P") + :description("Search predicate") argparse_for_render(c) end @@ -239,7 +241,7 @@ mksubcmd(function(c) c:flag("--verbose") :description("Be chatty on stderr about the generated comand stream") c:option("--escape") - -- TODO: :choices("posix", "extended", "human") + :choices({"posix", "extended", "human"}) :default("posix") :description("Control how special characters in paths are escaped") c:flag("--no-human-escape") @@ -796,10 +798,10 @@ mksubcmd(function(c) c:argument("db2") c:option("--flavor"):default("all") :description("Database aspects to compare") - -- TODO :choices("hash", "path", "both", "supers", "all") + :choices({"hash", "path", "both", "supers", "obsv", "all"}) c:option("--which"):default("symm") :description("Direction of comparison") - -- TODO :choices("sub", "super", "symm") + :choices({"sub", "super", "symm"}) c:flag("--no-headers") :description("Suppress headers in output") argparse_for_render(c) diff --git a/cdb-util b/cdb-util index 4ba6c1c..d38ce2e 100755 --- a/cdb-util +++ b/cdb-util @@ -120,7 +120,7 @@ mksubcmd(function(c) :description("Escape input records, usually for shells") c:argument("how"):default("posix") :description("How to escape lines") - -- TODO: :choices("digest", "posix", "extended", "human") + :choices({ "digest", "posix", "extended", "human" }) argparse_flag_nul(c) argparse_flag_inul(c) end,