Skip to main content

theme_styles

Function theme_styles 

Source
pub fn theme_styles(theme: &str) -> (Style, Style)
Expand description

Returns (badge_style, accent_style) for the given theme name.

Available themes: "cyan" (default), "magenta", "green", "blue", "yellow", "red".

Used by the #[cli(theme = "...")] attribute โ€” called from generated code.

ยงExample

let (badge, accent) = cli_ui::styles::theme_styles("green");
let painted = cli_ui::styles::paint(badge, " mytool ");
Examples found in repository?
examples/mini_cargo.rs (line 671)
659fn main() {
660    let cmd = match Cmd::parse() {
661        Ok(c) => c,
662        Err(e) => bail!("{}", e),
663    };
664    let global = Cmd::global();
665
666    header!(
667        "cargo-mini",
668        env!("CARGO_PKG_VERSION"),
669        "The Rust package manager (emulator)",
670        "no real side effects โ€” safe to tab-complete",
671        badge = cli_ui::styles::theme_styles("yellow").0
672    );
673
674    if global.verbose {
675        phase!("verbose", "verbose output enabled");
676    }
677
678    match cmd {
679        Cmd::Build(opt) => cmd_build(&opt, global),
680        Cmd::Run(opt) => cmd_run(&opt, global),
681        Cmd::Add(opt) => cmd_add(&opt, global),
682        Cmd::Remove(opt) => cmd_remove(&opt, global),
683        Cmd::New(opt) => cmd_new(&opt, global),
684        Cmd::Init(opt) => cmd_init(&opt, global),
685        Cmd::Test(opt) => cmd_test(&opt, global),
686        Cmd::Check(opt) => cmd_check(&opt, global),
687        Cmd::Clean(opt) => cmd_clean(&opt, global),
688        Cmd::Metadata(opt) => cmd_metadata(&opt, global),
689        Cmd::Update(opt) => cmd_update(&opt, global),
690        Cmd::Info(opt) => cmd_info(&opt, global),
691        Cmd::Import(opt) => cmd_import(&opt, global),
692    }
693}