Skip to content

Commit

Permalink
feat(cli): bring back cli colors using clap v3 styling interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-aksamentov committed Sep 8, 2023
1 parent 0b2ded4 commit 42fb63f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 34 deletions.
52 changes: 25 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages_rs/nextclade-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ publish = false

[dependencies]
assert2 = "=0.3.11"
clap = { version = "=4.3.10", features = ["derive"] }
clap_complete = "=4.3.1"
clap_complete_fig = "=4.3.1"
clap = { version = "=4.4.2", features = ["derive", "color", "unicode", "unstable-styles"] }
clap_complete = "=4.4.1"
clap_complete_fig = "=4.4.0"
color-eyre = "=0.6.2"
comfy-table = "=7.0.1"
crossbeam = "=0.8.2"
Expand Down
10 changes: 10 additions & 0 deletions packages_rs/nextclade-cli/src/cli/nextclade_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::cli::nextclade_dataset_list::nextclade_dataset_list;
use crate::cli::nextclade_loop::nextclade_run;
use crate::cli::verbosity::{Verbosity, WarnLevel};
use crate::io::http_client::ProxyConfig;
use clap::builder::styling;
use clap::{ArgGroup, CommandFactory, Parser, Subcommand, ValueEnum, ValueHint};
use clap_complete::{generate, Generator, Shell};
use clap_complete_fig::Fig;
Expand All @@ -27,10 +28,19 @@ lazy_static! {
pub static ref SHELLS: Vec<&'static str> = ["bash", "elvish", "fish", "fig", "powershell", "zsh"].to_vec();
}

fn styles() -> styling::Styles {
styling::Styles::styled()
.header(styling::AnsiColor::Green.on_default() | styling::Effects::BOLD)
.usage(styling::AnsiColor::Green.on_default() | styling::Effects::BOLD)
.literal(styling::AnsiColor::Blue.on_default() | styling::Effects::BOLD)
.placeholder(styling::AnsiColor::Cyan.on_default())
}

#[derive(Parser, Debug)]
#[clap(name = "nextclade")]
#[clap(author, version)]
#[clap(verbatim_doc_comment)]
#[clap(styles = styles())]
/// Viral genome alignment, mutation calling, clade assignment, quality checks and phylogenetic placement.
///
/// Nextclade is a part of Nextstrain: https://nextstrain.org
Expand Down
7 changes: 3 additions & 4 deletions packages_rs/nextclade/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ auto_ops = "=0.3.0"
bio = "=1.3.1"
bio-types = "=1.0.0"
chrono = { version = "=0.4.26", default-features = false, features = ["clock", "std", "wasmbind"] }
clap = { version = "=4.3.10", features = ["derive"] }
clap-verbosity-flag = "=2.0.1"
clap_complete = "=4.3.1"
clap_complete_fig = "=4.3.1"
clap = { version = "=4.4.2", features = ["derive", "color", "unicode", "unstable-styles"] }
clap_complete = "=4.4.1"
clap_complete_fig = "=4.4.0"
color-eyre = "=0.6.2"
csv = "=1.2.2"
ctor = "=0.2.2"
Expand Down

1 comment on commit 42fb63f

@vercel
Copy link

@vercel vercel bot commented on 42fb63f Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nextclade – ./

nextclade.vercel.app
nextclade-git-master-nextstrain.vercel.app
nextclade-nextstrain.vercel.app

Please sign in to comment.