Parse Command-Line Arguments in Larzscript
Parse --flag=value pairs and positional arguments out of argv, without a full CLI framework.
Values use the unambiguous --name=value form; a bare --verbose becomes a boolean flag set to true.
larzscript pkg install args
Code
import "args" as args_ let p = args_.parse(["build", "--target=release", "--verbose"]) print(p["positional"]) print(p["flags"]["target"]) print(args_.flag(p, "verbose", false))
Output
[build] release true
Related
larzargsCLI flag parsing→Build a CLI Tool with Subcommands in LarzscriptBuild a real command-line tool with named subcommands and auto-generated help, the shape every larzscript-* showcase app in this ecosystem uses.→Read a File Line by Line in LarzscriptRead a text file's contents and split it into lines - the everyday first step of any script that processes a file.→Pretty-Print a Table in LarzscriptRender tabular data as an aligned ASCII table for the terminal, or Markdown for a README.→