Skip to content

Commit

Permalink
support ls --help
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcarlisle committed Mar 17, 2024
1 parent e81d5f7 commit 6b488e4
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions l3sys-query.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.")
Expand All @@ -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")
Expand Down

0 comments on commit 6b488e4

Please sign in to comment.