[latex3-commits] [latex3/l3sys-query] main: support ls --help (3bc7f48)

github at latex-project.org github at latex-project.org
Mon Mar 18 08:54:16 CET 2024


Repository : https://github.com/latex3/l3sys-query
On branch  : main
Link       : https://github.com/latex3/l3sys-query/commit/3bc7f48e2a9966a8d8924fc6d84054af77335be4

>---------------------------------------------------------------

commit 3bc7f48e2a9966a8d8924fc6d84054af77335be4
Author: David Carlisle <d.p.carlisle at gmail.com>
Date:   Sun Mar 17 23:31:18 2024 +0000

    support ls --help


>---------------------------------------------------------------

3bc7f48e2a9966a8d8924fc6d84054af77335be4
 l3sys-query.lua | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/l3sys-query.lua b/l3sys-query.lua
index 0d860ae..93f6170 100755
--- a/l3sys-query.lua
+++ b/l3sys-query.lua
@@ -235,6 +235,8 @@ local function parse_args()
     -- No options are allowed in position 1, so filter those out
     if a == "--version" or a == "-v" then
       cmd = "version"
+    elseif a == "--help" or a == "-h" then
+      cmd = "help"
     elseif not match(a,"^%-") then
       cmd = a
     end
@@ -523,11 +525,13 @@ end
 --
 -- Execute the given command
 --
-
+if cmd == "help" then
+help()
+exit(0)
+elseif cmd == "version" then
+version()
+exit(0)
 -- Only 'known' commands do anything at all
-if cmd == "version" then
-  version()
-  exit(0)
 elseif not cmd_impl[cmd] then
   if cmd == "" then
     info_and_quit(script_name .. ": No " .. script_name .. " command specified.")
@@ -541,7 +545,13 @@ end
 -- Check options are valid for cmd
 for k,_ in pairs(options) do
   local cmds = option_list[k].cmds
-  if not cmds then
+  if k == "help" then
+    help()
+    exit(0)
+  elseif k == "version" then
+    version()
+    exit(0)
+  elseif not cmds then
     -- Should not be possible:
     -- everything except --help and --version should have an entry
     print("Internal error")





More information about the latex3-commits mailing list.