Skip to content

Commit

Permalink
Hack around cliargs to provide "help" flag
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMagician23 committed Nov 23, 2023
1 parent 02f31a9 commit 12eaa77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions busted/modules/cli.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ return function(options)
-- Parse the cli arguments
local cliArgs, cliErr = cli:parse(args)
if not cliArgs then
if cliErr:match("^Usage") then
return { help = true, helpText = cliErr }, nil
end

return nil, appName .. ': error: ' .. cliErr .. '; re-run with --help for usage.'
end

Expand Down
5 changes: 5 additions & 0 deletions busted/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ return function(options)
exit(1, forceExit)
end

if cliArgs.help then
io.stdout:write(cliArgs.helpText)
exit(0, forceExit)
end

if cliArgs.version then
-- Return early if asked for the version
print(busted.version)
Expand Down

0 comments on commit 12eaa77

Please sign in to comment.