args

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 8 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL