#[non_exhaustive]pub struct Surface {
pub binary: String,
pub mount: String,
pub about: String,
pub version: Option<String>,
pub arguments: Vec<SurfaceArgument>,
pub inherited_arguments: Vec<SurfaceArgument>,
pub commands: Vec<SurfaceCommand>,
pub usage_kdl: String,
pub mount_line: String,
pub notes: BTreeMap<String, String>,
}surface-model only.Expand description
What a user sees of one Clap command tree.
Build it with Surface::new or Surface::from_command. It is plain
data: a test compares a render of it with a committed file, and a template
reads its fields. A field can join it in a minor release.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.binary: StringExecutable name declared by the root Clap command.
mount: StringThe mise task name that runs the CLI.
about: StringRoot command description.
version: Option<String>Root package version, when Clap declares one.
arguments: Vec<SurfaceArgument>Arguments and flags declared directly on the root, in Clap order.
inherited_arguments: Vec<SurfaceArgument>Ancestor global arguments, always empty for the root.
commands: Vec<SurfaceCommand>Root subcommands in Clap declaration order, including hidden commands.
usage_kdl: StringUsage KDL for the mise task name.
mount_line: StringThe exact #USAGE mount line for the mise task.
notes: BTreeMap<String, String>Prose the CLI adds by name, for its documentation templates.
Implementations§
Source§impl Surface
impl Surface
Sourcepub fn new<C: CommandFactory>(mount: impl Into<String>) -> Self
pub fn new<C: CommandFactory>(mount: impl Into<String>) -> Self
The surface of the Clap parser type C.
mount is the mise task name that runs the CLI, such as toy in
mise run toy status. See Self::from_command.
Sourcepub fn from_command(command: Command, mount: impl Into<String>) -> Self
pub fn from_command(command: Command, mount: impl Into<String>) -> Self
The surface of a Clap command tree.
mount is the mise task name that runs the CLI. The Usage KDL and the
#USAGE mount line use it. Hidden commands are listed with hidden
set. The Usage KDL holds the -h/--help flag and help subcommand
ctl-core declares on every command, as
apply_defaults does for parsing. The
lists of arguments and commands leave them out.
Sourcepub fn note(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn note(self, name: impl Into<String>, value: impl Into<String>) -> Self
Add the CLI’s own prose under name, for one template section or
reader. A template reads it as surface.notes.<name>. A later note of
the same name replaces an earlier one.
Sourcepub fn long_options_without_short(&self) -> Vec<(String, String)>
pub fn long_options_without_short(&self) -> Vec<(String, String)>
Long flags that have no short, as (command path, long name).
The root path is empty. Inherited globals are not repeated on children.
Hidden flags are included so a long-only option cannot hide from the
check. FormatLong and
ColorLong leave --format / --color
without shorts on purpose; pass those names to Self::require_shorts.
Sourcepub fn require_shorts<'a>(
&self,
allow: impl IntoIterator<Item = &'a str>,
) -> Result<(), String>
pub fn require_shorts<'a>( &self, allow: impl IntoIterator<Item = &'a str>, ) -> Result<(), String>
Fail when a long option has no visible short, except tokens in
allow.
A root allowance is the displayed long option (--format). A nested
allowance includes its command path (status --archived). ctl-core’s
shared flags that leave a letter free for the CLI on purpose
(--format for -f/--file, --color for -c) belong there.
§Errors
Returns a message that lists every long option without a short,
outside allow.