Skip to main content

Module args

Module args 

Source
Expand description

Per-command argument values.

Each registered command declares an args_schema: Vec<ArgSpec> (DESIGN.md §5.11, §B.1) describing the kinds, names, prompts and defaults for its arguments. The dispatcher carries the concrete values through Args.

Four Args shapes coexist:

  • Args::None – universal “no args” form (most motions / operators).
  • Args::Char(char) / Args::String(String) – single-arg shortcuts for the common cases (vim’s f<x> takes a char; :set <opt> takes a string). Predates B.1 and stays for ergonomic registration.
  • Args::List(Vec<ArgValue>) – multi-arg form, positional values matching the command’s args_schema in declaration order. This is what palette-driven entry, plugin invocations, and the :-line parser front-end produce for ex-commands with structured args (:s/pat/repl/flags, :g/pat/body).
  • Args::Bytes(Vec<u8>) – escape hatch for plugin-supplied richer args: opaque bytes (msgpack by convention) that cross the WIT boundary unchanged. Built-in commands never read it; host paths that need positional values drop it.

ArgValue is a small typed enum – not a dynamic value bag – so callers get static type checks at the boundary.

Structs§

ArgSpec
One argument’s metadata. A command’s args_schema is the ordered list of these. Drives:

Enums§

ArgDefault
What the runtime should fall back to when an arg is unsupplied at invocation time (DESIGN.md §B.1). For interactive entry, the fallback chain is: caller-supplied value -> default -> prompt the user.
ArgKind
Type tag for an argument. Mirrors ArgValue one-for-one and is what an args_schema entry declares for each positional argument.
ArgValue
One argument’s typed value. The variants mirror ArgKind one-for-one.
Args
The concrete argument values carried by a CommandInvocation. See the module docs for when each shape is used.