#[derive(Grouped)]
pub struct ResultHello(String);
#[command]
pub fn hello(args: Entry) -> ResultHello {
let name = args
.pick_or(&arg![String], || "World".into())
.unwrap();
ResultHello(name)
}
#[renderer(buffer)]
pub fn render_hello(hello: ResultHello) {
r_println!("Hello, {}", hello.0);
}
✦ Command is just a
Function,
✦ Renderer is just a
Function,
✦ Mingling wires them
together
✦ with no builder boilerplate.
#[command] turns a function into a
subcommand
#[renderer] — output, decoupled from
logic
pick / pick_or — typed args via
arg-picker
~# my-cli hello
Hello, World!
~# my-cli hello Mingling
Hello, Mingling!
#[command(entry = EntryHello)]
pub fn hello() { /* ... */ }
#[command]
pub fn bye() { /* ... */ }
#[completion(EntryHello)]
pub fn complete_hello(ctx: &ShellContext) -> Suggest {
if ctx.previous_word == "hello" {
suggest! {
"Alice": "The Sender",
"Bob": "The Receiver",
}
} else {
suggest! {}
}
}
✦ hello offers Alice
& Bob,
✦ bye gets a friendly
farewell,
✦ Mingling completes by
context —
✦ suggestions born at runtime.