File: script.lua

package info (click to toggle)
lua-argparse 0.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 356 kB
  • sloc: python: 38; makefile: 15
file content (40 lines) | stat: -rwxr-xr-x 801 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env lua

local Parser = require "argparse"

local parser = Parser()
   :description "A testing program."
   :add_help_command()
   :require_command(false)

parser:argument "input"

parser:flag "-v" "--verbose"
   :description "Sets verbosity level."
   :target "verbosity"
   :count "0-2"

local install = parser:command "install"
   :description "Install a rock."

install:argument "rock"
   :description "Name of the rock."

install:argument "version"
   :description "Version of the rock."
   :args "?"

install:option "-f" "--from"
   :description "Fetch the rock from this server."
   :target "server"

parser:get_usage()
parser:get_help()
local args = parser:parse()

print(args.input)
print(args.verbosity)
print(args.install)
print(args.rock)
print(args.version)
print(args.server)