#[non_exhaustive]pub struct SpecOutput {
pub name: String,
pub media_type: Option<String>,
pub framing: Framing,
pub help: Option<String>,
pub schema: Option<String>,
pub default: bool,
pub hide: bool,
pub select: Option<String>,
}Expand description
One thing a command can write.
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.name: StringThe token a user types for it, e.g. human, json, ndjson.
media_type: Option<String>The media type of the bytes, independent of their stream framing.
framing: FramingThe wire format, which is what a consumer keys off.
help: Option<String>§schema: Option<String>A JSON Schema for what is written, carried verbatim.
Opaque on purpose: usage-lib has no runtime JSON dependency and is not going to grow one to hold a string it never inspects. Consumers that want it parsed — today that is only the MCP server — parse it themselves and fall back to the raw text, so a malformed schema degrades rather than failing a spec.
default: boolWhat the command writes when nothing selects otherwise.
hide: boolDeclared in order to be taken away: a command that inherits a CLI-wide output it
cannot produce redeclares the name with hide=#true. The same spelling as a
hidden choice or alias.
select: Option<String>A boolean flag whose presence picks this output, for the --json spelling.
Implementations§
Source§impl SpecOutput
impl SpecOutput
pub fn new(name: impl Into<String>) -> Self
pub fn framing(self, framing: Framing) -> Self
pub fn media_type(self, media_type: impl Into<String>) -> Self
pub fn help(self, help: impl Into<String>) -> Self
pub fn schema(self, schema: impl Into<String>) -> Self
pub fn default_output(self) -> Self
Sourcepub fn select_argv(&self, cmd: &SpecCommand) -> Option<Selector>
pub fn select_argv(&self, cmd: &SpecCommand) -> Option<Selector>
How this output is asked for, given the command it belongs to.
None when no flag selects it. This is valid for an always-produced output;
generated per-output SDK methods require a selector and therefore omit it.
Trait Implementations§
Source§impl Clone for SpecOutput
impl Clone for SpecOutput
Source§fn clone(&self) -> SpecOutput
fn clone(&self) -> SpecOutput
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SpecOutput
impl Debug for SpecOutput
Source§impl Default for SpecOutput
impl Default for SpecOutput
Source§fn default() -> SpecOutput
fn default() -> SpecOutput
Auto Trait Implementations§
impl Freeze for SpecOutput
impl RefUnwindSafe for SpecOutput
impl Send for SpecOutput
impl Sync for SpecOutput
impl Unpin for SpecOutput
impl UnsafeUnpin for SpecOutput
impl UnwindSafe for SpecOutput
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more