65 lines
1.6 KiB
Rust
65 lines
1.6 KiB
Rust
use anstyle::{AnsiColor, Color, Style};
|
|
use indicatif::ProgressStyle;
|
|
|
|
pub fn clap_styles() -> clap::builder::Styles {
|
|
clap::builder::Styles::styled()
|
|
.usage(
|
|
Style::new()
|
|
.bold()
|
|
.fg_color(Some(Color::Ansi(AnsiColor::Blue))),
|
|
)
|
|
.header(
|
|
Style::new()
|
|
.bold()
|
|
.fg_color(Some(Color::Ansi(AnsiColor::Blue))),
|
|
)
|
|
.literal(
|
|
Style::new()
|
|
.bold()
|
|
.fg_color(Some(Color::Ansi(AnsiColor::BrightBlack))),
|
|
)
|
|
.invalid(
|
|
Style::new()
|
|
.bold()
|
|
.fg_color(Some(Color::Ansi(AnsiColor::Red))),
|
|
)
|
|
.error(
|
|
Style::new()
|
|
.bold()
|
|
.fg_color(Some(Color::Ansi(AnsiColor::Red))),
|
|
)
|
|
.valid(
|
|
Style::new()
|
|
.bold()
|
|
.underline()
|
|
.fg_color(Some(Color::Ansi(AnsiColor::Green))),
|
|
)
|
|
.placeholder(Style::new().fg_color(Some(Color::Ansi(AnsiColor::White))))
|
|
}
|
|
|
|
#[expect(clippy::unwrap_used)]
|
|
pub fn progress_big() -> ProgressStyle {
|
|
return ProgressStyle::default_bar()
|
|
.template(
|
|
" {spinner:.green} [{elapsed_precise}] [{bar:40.green/dim}] {pos:>7}/{len:7} {msg:.dim}",
|
|
)
|
|
.unwrap()
|
|
.progress_chars("=>-")
|
|
.tick_strings(&[
|
|
"⠉⠉", "⠈⠙", "⠀⠹", "⠀⢸", "⠀⣰", "⢀⣠", "⣀⣀", "⣄⡀", "⣆⠀", "⡇⠀", "⠏⠀", "⠋⠁", "⣏⣹",
|
|
]);
|
|
}
|
|
|
|
#[expect(clippy::unwrap_used)]
|
|
pub fn progress_bytes() -> ProgressStyle {
|
|
return ProgressStyle::default_bar()
|
|
.template(
|
|
" {bar:16.red/white.dim} {elapsed_precise:.dim} {bytes:>10}/{total_bytes:>10} {msg:.dim} ({eta})",
|
|
)
|
|
.unwrap()
|
|
.progress_chars("---")
|
|
.tick_strings(&[
|
|
"⠉⠉", "⠈⠙", "⠀⠹", "⠀⢸", "⠀⣰", "⢀⣠", "⣀⣀", "⣄⡀", "⣆⠀", "⡇⠀", "⠏⠀", "⠋⠁", "⣏⣹",
|
|
]);
|
|
}
|