Command¶
Import system.cli. See the CLI guide for examples.
Command¶
Declarative CLI definition. Parsing consumes arguments without an executable name and never exits.
constructor¶
Creates a command; invalid names or conflicting definitions return errors from parse.
version¶
Sets version output and enables --version/-V for this command and its descendants.
description¶
Sets text included in automatically generated help.
require_subcommand¶
Requires one of the declared subcommands; --help and --version still return normal outcomes.
positional¶
Adds an ordered string positional; only the last positional can collect multiple arguments.
public fun positional(
name: string,
required: bool = false,
multiple: bool = false,
description: string = ""
): Command
string_option¶
Adds a string option. Optional values default to empty; repeated occurrences are collected, with the last returned by get_string.
public fun string_option(
name: string,
short: string = "",
default_value: string = "",
required: bool = false,
description: string = ""
): Command
int_option¶
Adds a decimal 32-bit integer option. Optional values default to zero; required options ignore defaults.
public fun int_option(
name: string,
short: string = "",
default_value: int = 0,
required: bool = false,
description: string = ""
): Command
flag¶
Adds a boolean option defaulting to false; repeated occurrences remain true.
choices¶
Restricts a previously declared string, positional, or integer argument to these exact values.
subcommand¶
Snapshots a child definition. Later edits to the child do not mutate its attached copy.
parse¶
Parses explicit arguments; pass System.args to parse the process arguments. Returns errors for invalid definitions, arguments, or conversions. Does not exit the process.