]> hydra-www.ietfng.org Git - csdb/commitdiff
Add :choices() to argparse options
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Tue, 15 Nov 2022 03:16:15 +0000 (03:16 +0000)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Tue, 15 Nov 2022 03:16:15 +0000 (03:16 +0000)
Now that Debian has pulled in a sufficiently new lua-argparse (though
only in testing).

cdb
cdb-util

diff --git a/cdb b/cdb
index 32540fddc1162e55e017d5e66fdc682d4afc3e13..e9fbb420a365a19ad9a24225f0e27abdcb1d563e 100755 (executable)
--- 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)
index 4ba6c1cd592298e42807bef5307854cfab062908..d38ce2e2aebb61888bf30543afa33a64954dfc5e 100755 (executable)
--- 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,