Skip to content

Commit

Permalink
Add example of --help
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMagician23 committed Dec 13, 2023
1 parent 538417a commit 222e104
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions examples/05_help.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/lua

--[[
Shows how to use the builtin help functions to create a -h/--help option.
--]]

local cli = require "cliargs"

function help()
cli:print_help()
os.exit(0)
end

cli:flag("-h, --help", "prints the help and usage text", help)

local args, err = cli:parse()

if not args then
print(err)
os.exit(1)
end

0 comments on commit 222e104

Please sign in to comment.