Documentation
¶
Overview ¶
Package args provides an argparse-style command-line argument parser for Starlark scripts run by starcli. The surface deliberately mirrors Python's argparse so it reads familiarly:
load("args", "ArgumentParser")
p = ArgumentParser(description = "greet someone")
p.add_argument("--name", default = "World", help = "who to greet")
p.add_argument("--count", type = int, default = 1)
p.add_argument("--shout", action = "store_true")
p.add_argument("file", help = "input file")
ns = p.parse_args() # parses the script's args (argv[1:])
print(ns.name, ns.count, ns.shout, ns.file)
args.argv is the full argument vector (argv[0] is the script name or "-c", like Python's sys.argv); parse_args defaults to argv[1:].
Index ¶
Constants ¶
View Source
const ModuleName = "args"
ModuleName defines the module name.
Variables ¶
This section is empty.
Functions ¶
func NewModule ¶
func NewModule(argv []string) starlet.ModuleLoader
NewModule creates the args module loader, capturing the script argv.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.