Struct Styles

struct Styles { ... }

Terminal styling definitions

See also [Command::styles][crate::Command::styles].

Example

clap v3 styling

# use clap_builder as clap;
# use clap::builder::styling::*;
let styles = Styles::styled()
    .header(AnsiColor::Yellow.on_default())
    .usage(AnsiColor::Green.on_default())
    .literal(AnsiColor::Green.on_default())
    .placeholder(AnsiColor::Green.on_default());

Implementations

impl Styles

const fn get_header(self: &Self) -> &Style

General Heading style, e.g. [help_heading][crate::Arg::help_heading]

const fn get_error(self: &Self) -> &Style

Error heading

const fn get_usage(self: &Self) -> &Style

Usage heading

const fn get_literal(self: &Self) -> &Style

Literal command-line syntax, e.g. --help

const fn get_placeholder(self: &Self) -> &Style

Descriptions within command-line syntax, e.g. [value_name][crate::Arg::value_name]

const fn get_valid(self: &Self) -> &Style

Highlight suggested usage

const fn get_invalid(self: &Self) -> &Style

Highlight invalid usage

impl Styles

const fn plain() -> Self

No terminal styling

const fn styled() -> Self

Default terminal styling

const fn header(self: Self, style: Style) -> Self

General Heading style, e.g. [help_heading][crate::Arg::help_heading]

const fn error(self: Self, style: Style) -> Self

Error heading

const fn usage(self: Self, style: Style) -> Self

Usage heading

const fn literal(self: Self, style: Style) -> Self

Literal command-line syntax, e.g. --help

const fn placeholder(self: Self, style: Style) -> Self

Descriptions within command-line syntax, e.g. [value_name][crate::Arg::value_name]

const fn valid(self: Self, style: Style) -> Self

Highlight suggested usage

const fn invalid(self: Self, style: Style) -> Self

Highlight invalid usage

impl Clone for Styles

fn clone(self: &Self) -> Styles

impl Debug for Styles

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

impl Default for Styles

fn default() -> Self

impl Freeze for Styles

impl RefUnwindSafe for Styles

impl Send for Styles

impl Sync for Styles

impl Unpin for Styles

impl UnwindSafe for Styles

impl<T> Any for Styles

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Styles

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Styles

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

impl<T> CloneToUninit for Styles

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

impl<T> From for Styles

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Styles

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for Styles

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for Styles

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

impl<T, U> TryInto for Styles

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