命令行
Translation status: 繁體中文 reader-locale proof. Term names and code fences follow the zh-Hant pack; supporting prose may still be English.
CLI root with options, operands, subcommands, and module mounts.
Syntax: @ 命令行 <name>
Category#
cli
Related#
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 { 名稱 = "NAME" }` sets the CLI
# program name using brace-delimited key-value pairs
# • Multi-annotation CLI setup — combining `@ cli` with `@ 選項` 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, 選項, annotation-sugar
# =============================================================================
# Braced @ cli — canonical program name record
#
# TARGET: annotation-sugar stage 2
# PAIR: sugar `@ cli "NAME"` (see 選項/optio.fab)
@ 命令行 { name = "annotation-sugar-smoke" }
@ option { binding = verbose, short = "v", long = "verbose", type = bool, description = "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`, `@ 描述`, `@ 選項`,
# `@ 操作數`, `@ 命令`, and `@ alias` compose a complete CLI
# application definition
# • Subcommands — `@ 命令 "greet"` declares a subcommand with its own
# options and operands
# • Module mounting — `@ imperia` imports command modules from packages
#
# Common mistakes:
# • attaching `@ cli` to a `函式` instead of an `入口` (SEM009), or reusing duplicate CLI flags or binding names within the same CLI surface
#
# See also: 命令, imperia, 選項, 操作數, 引數, 描述,
# 全局, versio, alias
# =============================================================================
# cli — structured CLI annotation tour
#
# @ cli / @ versio / @ 描述 / @ 選項 / @ 操作數 / @ 命令 / @ alias
# @ imperia mounts imported command modules (see package-cli fixture).
#
# GRAMMAR:
# cliDecl :← '@' 'cli' stringLit
# 入口 引數 args { ... }
#
# EXPECTED OUTPUT:
# Requires CLI flags/args at run time; no fixed stdout contract.
#
# BACKEND:
# Rust runtime whitelist (missing operand '名稱'); Go compile whitelist.
# Cross-ref 選項/, 操作數/, 描述/, 全局/, 引數/ keyword dirs.
@ 命令行 "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 名稱 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"
}