pub fn usage_line(path: &[&str], meta: &CommandMeta<'_>) -> StringExpand description
The Usage: line’s body, without the Usage: prefix.
path is the command as invoked, starting with the binary: ["mise", "config", "ls"].
The metadata holds a tree and each node knows its own name, so the path a particular
invocation took has to come from the caller — which is the parser, or a help command
naming a command explicitly.
use usage_argv::help::usage_line;
use usage_argv::spec::{ArgMeta, CommandMeta, FlagMeta};
use usage_argv::{Arg, Command, Flag};
static FORCE: Flag = Flag { name: "force", longs: &["force"], ..Flag::BOOL };
static TOOL: Arg = Arg { name: "TOOL", ..Arg::REQUIRED };
static CMD: Command = Command {
name: "use",
flags: &[&FORCE],
args: &[&TOOL],
..Command::EMPTY
};
static META: CommandMeta = CommandMeta {
cmd: &CMD,
flags: &[FlagMeta { flag: &FORCE, ..FlagMeta::EMPTY }],
args: &[ArgMeta { arg: &TOOL, required: true, ..ArgMeta::EMPTY }],
..CommandMeta::EMPTY
};
assert_eq!(usage_line(&["mise", "use"], &META), "mise use [--force] <TOOL>");