Skip to main content

Spec

Struct Spec 

Source
pub struct Spec<'a> {
Show 17 fields pub name: &'a str, pub bin: Option<&'a str>, pub version: Option<&'a str>, pub long_version: Option<&'a str>, pub author: Option<&'a str>, pub license: Option<&'a str>, pub repository: Option<&'a str>, pub source_code_link_template: Option<&'a str>, pub min_usage_version: Option<&'a str>, pub about: Option<&'a str>, pub long_about: Option<&'a str>, pub usage: Option<&'a str>, pub help_template: Option<&'a str>, pub default_subcommand: Option<&'a str>, pub multicall: bool, pub views: &'a [ViewMeta<'a>], pub root: &'a CommandMeta<'a>,
}
Expand description

A whole CLI: the root command plus what describes the program itself.

Fields§

§name: &'a str

The program’s name.

§bin: Option<&'a str>

The binary as invoked, when it differs from name.

§version: Option<&'a str>§long_version: Option<&'a str>

Extended version text used by --version; -V falls back to version.

§author: Option<&'a str>

Package authorship text for generated references.

§license: Option<&'a str>

SPDX expression or other license label for generated references.

§repository: Option<&'a str>

Source repository URL for generated references and integrations.

§source_code_link_template: Option<&'a str>

A tera template turning a command path into a link to the code implementing it.

Rendered with path bound to the command’s words joined by /, so a docs generator can put a “view source” link on every command page. Distinct from Self::repository, which is the plain project URL: a deep link with a {{path}} placeholder cannot be turned back into one without knowing a particular forge’s URL layout.

§min_usage_version: Option<&'a str>

The oldest usage that can read this spec, when the CLI says.

Written first, before anything a usage too old to understand would choke on — which is the whole point of it, and why it is declared rather than worked out here: it is the CLI’s claim about which consumers it means to keep working.

§about: Option<&'a str>§long_about: Option<&'a str>§usage: Option<&'a str>

An exact usage synopsis, including the Usage: prefix, when the generated shape needs alternatives that cannot be inferred from one command grammar.

§help_template: Option<&'a str>

How every page in this CLI is laid out, as named sections.

A template names the six pre-rendered sections — {{about}}, {{usage}}, {{commands}}, {{args}}, {{flags}}, {{after_help}} — and may reorder, omit or wrap them. See crate::help::SECTIONS for what each one covers and crate::help::unsupported_section for the rule an author’s template is held to.

§default_subcommand: Option<&'a str>

Which command the root falls back to when a word matches no subcommand. mise uses this so mise foo completes as mise run foo.

§multicall: bool

Whether argv[0]’s basename selects a subcommand (busybox-style applets).

clap’s multicall. The dispatcher names (name / bin) are skipped; any other basename is parsed as the first word. Path components and a trailing .exe are stripped. The parser itself does not see argv[0]; crate::multicall_applet is what a process entry applies before calling it.

§views: &'a [ViewMeta<'a>]

Spec-declared executable views promoted from commands below the root.

§root: &'a CommandMeta<'a>

The root command, and the home of everything a spec declares at its top level.

A KDL spec has one place for surrounding text and examples — the top level — and the reference reads what is written there as the root’s and as the default for every other page. So they live here, on the root’s metadata, rather than in a second set of fields on the spec: two homes for one declaration is two answers to one question, and to_kdl and the renderer picked differently.

Implementations§

Source§

impl Spec<'_>

Source

pub const EMPTY: Spec<'static>

A spec with nothing declared but a root, for use with struct update syntax.

Here so that gaining a field does not break every literal that builds one.

Source

pub const fn view(&self) -> SpecView<'_>

Borrow this spec for runtime identity or sparse metadata overlays.

Source§

impl Spec<'_>

Source

pub fn to_kdl(&self) -> String

Write this CLI as a usage spec, in KDL.

Trait Implementations§

Source§

impl<'a> Clone for Spec<'a>

Source§

fn clone(&self) -> Spec<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Spec<'a>

Source§

impl<'a> Debug for Spec<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Spec<'a>

§

impl<'a> RefUnwindSafe for Spec<'a>

§

impl<'a> Send for Spec<'a>

§

impl<'a> Sync for Spec<'a>

§

impl<'a> Unpin for Spec<'a>

§

impl<'a> UnsafeUnpin for Spec<'a>

§

impl<'a> UnwindSafe for Spec<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.