Kết xuấtvi

cli

Translation status: Tiếng Việt reader-locale proof. Code fences render through the vi pipeline; prose is canonical Latin.

CLI root with options, operands, subcommands, and module mounts.

Syntax: @ cli <name>

Category#

cli

Examples#

radix/corpus/annotation-sugar/cli-braced.fab (canonical · annotation)#

Braced canonical @ cli program marker.

# =============================================================================
# cli — Braced canonical @ cli program marker.
# =============================================================================
#
# What this teaches:
#   • Braced annotation syntax — `@ cli { nomen = "NAME" }` sets the CLI
#     program name using brace-delimited key-value pairs
#   • Multi-annotation CLI setup — combining `@ cli` with `@ optio` to
#     configure a command-line program and its options
#
# Common mistakes:
#   • mixing braced and sugar annotation syntax on the same declaration; pick one canonical form per annotation
#
# See also: cli, optio, annotation-sugar
# =============================================================================

# Braced @ cli — canonical program name record
#
# TARGET: annotation-sugar stage 2
# PAIR: sugar `@ cli "NAME"` (see optio/optio.fab)

@ cli { nomen = "annotation-sugar-smoke" }
@ option {
    binding = verbose,
    brevis = "v",
    longum = "verbose",
    typus = bool,
    descriptio = "Verbose mode",
}
main args args { }

radix/corpus/cli/cli.fab (canonical · annotation)#

CLI root with options, operands, subcommands, and module mounts.

# =============================================================================
# cli — CLI root with options, operands, subcommands, and module mounts.
# =============================================================================
#
# What this teaches:
#   • Full CLI framework — `@ cli`, `@ versio`, `@ descriptio`, `@ optio`,
#     `@ operandus`, `@ imperium`, and `@ alias` compose a complete CLI
#     application definition
#   • Subcommands — `@ imperium "greet"` declares a subcommand with its own
#     options and operands
#   • Module mounting — `@ imperia` imports command modules from packages
#
# Common mistakes:
#   • attaching `@ cli` to a `functio` instead of an `incipit` (SEM009), or reusing duplicate CLI flags or binding names within the same CLI surface
#
# See also: imperium, imperia, optio, operandus, argumenta, descriptio,
#   ubique, versio, alias
# =============================================================================

# cli — structured CLI annotation tour
#
# @ cli / @ versio / @ descriptio / @ optio / @ operandus / @ imperium / @ alias
# @ imperia mounts imported command modules (see package-cli fixture).
#
# GRAMMAR:
#   cliDecl :← '@' 'cli' stringLit
#   incipit argumenta args { ... }
#
# EXPECTED OUTPUT:
#   Requires CLI flags/args at run time; no fixed stdout contract.
#
# BACKEND:
#   Rust runtime whitelist (missing operand 'nomen'); Go compile whitelist.
#   Cross-ref optio/, operandus/, descriptio/, ubique/, argumenta/ keyword dirs.

@ cli "exemplum"
@ versio "0.1.0"
@ description "Faber CLI framework smoke exemplum"
@ option verbose short "v" long "verbose" type bool global description "Enable verbose output"
main args args {
}

@ command "greet"
@ alias "g"
@ description "Greet by name"
@ operand string nomen description "Name to greet"
fn greet() args args  void {
    if args.verbose {
        print "verbose"
    }
    print "Salve, §!"(args.nomen)
}

@ command "version"
@ alias "v"
fn version()  void {
    print "exemplum v0.1.0"
}