vyrn

std/args

7 exports, from std/args.vyrn.

Command-line argument parsing over args(), in Vyrn.

Four probes: flag, opt (--name value or --name=value), positionals and rest (a -- passthrough tail). There is no spec, no generated --help and no unknown-flag refusal; std/cli has those. Names match verbatim, dashes included, and -abc is one token. A token that starts with - before the first -- is a flag or option token; every token after -- is positional.

Dependencies

The import graph shows the whole library.

Imported by
fn opt(a: Args, name: String) -> Option<String>

The value of option name before the -- terminator, or None. The first occurrence wins. --name=value gives everything after the first =, which may be empty. --name value gives the next token unless it starts with -; then the option has no value and the answer is None.

fn rest(a: Args, terminator: String) -> Array<String>

The tokens after the first terminator; empty when it is absent.

Tests

8 test blocks in std/args.vyrn. CI runs all of them.

Test names
  • flag is exact-name presence before the terminator
  • opt reads the space form and the equals form
  • opt does NOT consume a following option-looking token
  • opt first occurrence wins, later duplicates ignored
  • positionals skip flags, option values, and honor the terminator
  • positionals over an empty argv is empty
  • rest returns only the tokens after the terminator
  • cliOf and cli agree in shape

Examples

2 programs in examples/ import this module. Each runs as WebAssembly and as a native binary.