Skip to content

Commit

Permalink
Merge pull request #207 from noamteyssier/206-add-colored-help
Browse files Browse the repository at this point in the history
206 add colored help
  • Loading branch information
noamteyssier authored Oct 8, 2024
2 parents ebbff85 + 58ce6ca commit 932393e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ggetrs"
version = "0.1.83"
version = "0.1.84"
edition = "2021"
license = "MIT"
description = "Efficient querying of biological databases from the command line"
Expand All @@ -21,7 +21,7 @@ default = ["pyo3/extension-module"]
[dependencies]
anyhow = "1.0.64"
bitvec = "1.0.1"
bon = "2.1.1"
bon = "2.3.0"
chrono = "0.4.22"
clap = { version = "4.0.18", features = ["derive"] }
clap_complete = "4.0.3"
Expand All @@ -33,10 +33,10 @@ polars = { version = "0.43.1", default-features = false, features = ["json"] }
pyo3 = { version = "0.22.2", features = ["extension-module", "anyhow"] }
regex = "1.6.0"
reqwest = { version = "0.12.5", features = [
"json",
"multipart",
"blocking",
"stream",
"json",
"multipart",
"blocking",
"stream",
] }
serde = { version = "1.0.144", features = ["derive"] }
serde-xml-rs = "0.6.0"
Expand Down
16 changes: 15 additions & 1 deletion src/cli/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,24 @@ use crate::{
blast::types::{BlastDatabase, BlastProgram},
ensembl::ENSEMBL_RELEASE_STR,
};
use clap::{Parser, Subcommand};
use clap::{
builder::{
styling::{AnsiColor, Effects},
Styles,
},
Parser, Subcommand,
};
use clap_complete::Shell;

// Configures Clap v3-style help menu colors
const STYLES: Styles = Styles::styled()
.header(AnsiColor::Green.on_default().effects(Effects::BOLD))
.usage(AnsiColor::Green.on_default().effects(Effects::BOLD))
.literal(AnsiColor::Cyan.on_default().effects(Effects::BOLD))
.placeholder(AnsiColor::Cyan.on_default());

#[derive(Parser)]
#[command(styles = STYLES)]
#[clap(author, version, about)]
#[clap(propagate_version = true)]
pub struct Cli {
Expand Down
23 changes: 8 additions & 15 deletions src/cli/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
utils::{match_output, OutputFormat},
};
use anyhow::Result;
use bon::builder;
use bon::{builder, Builder};
use clap::{Parser, Subcommand};
use serde_json::{json, Value};
use std::io::Write;
Expand Down Expand Up @@ -85,8 +85,7 @@ impl OutputArgs {
}
}

#[derive(Debug, Clone, Parser)]
#[builder]
#[derive(Debug, Clone, Parser, Builder)]
#[clap(next_help_heading = "STRING Network Arguments")]
/// Retrieves the network interactions for your input protein(s) in various text based formats
pub struct StringNetworkArgs {
Expand Down Expand Up @@ -146,8 +145,7 @@ impl StringNetworkArgs {
}
}

#[derive(Debug, Clone, Parser)]
#[builder]
#[derive(Debug, Clone, Parser, Builder)]
#[clap(next_help_heading = "STRING Homology Arguments")]
pub struct StringHomologyArgs {
/// List of genes to retrieve network for
Expand Down Expand Up @@ -175,8 +173,7 @@ impl StringHomologyArgs {
}
}

#[derive(Debug, Clone, Parser)]
#[builder]
#[derive(Debug, Clone, Parser, Builder)]
#[clap(next_help_heading = "STRING Mapping Identifiers Arguments")]
pub struct StringMappingArgs {
/// List of genes to retrieve network for
Expand Down Expand Up @@ -219,8 +216,7 @@ impl StringMappingArgs {
}

/// Gets all the STRING interaction partners of your proteins
#[derive(Debug, Clone, Parser)]
#[builder]
#[derive(Debug, Clone, Parser, Builder)]
#[clap(next_help_heading = "STRING Interactions Arguments")]
pub struct StringInteractionsArgs {
/// List of genes to retrieve network for
Expand Down Expand Up @@ -271,8 +267,7 @@ impl StringInteractionsArgs {
}

/// Performs the enrichment analysis of your set of proteins for the Gene Ontology, KEGG pathways, UniProt Keywords, PubMed publications, Pfam, InterPro and SMART domains.
#[derive(Debug, Clone, Parser)]
#[builder]
#[derive(Debug, Clone, Parser, Builder)]
#[clap(next_help_heading = "STRING Functional Enrichment Arguments")]
pub struct StringFunctionalEnrichmentArgs {
/// List of genes to retrieve network for
Expand Down Expand Up @@ -310,8 +305,7 @@ impl StringFunctionalEnrichmentArgs {
}

/// Gets the functional annotation (Gene Ontology, UniProt Keywords, PFAM, INTERPRO and SMART domains) of your list of proteins.
#[derive(Debug, Clone, Parser)]
#[builder]
#[derive(Debug, Clone, Parser, Builder)]
#[clap(next_help_heading = "STRING Functional Annotations Arguments")]
pub struct StringFunctionalAnnotationArgs {
/// List of genes to retrieve network for
Expand Down Expand Up @@ -352,8 +346,7 @@ impl StringFunctionalAnnotationArgs {
}

/// Tests if your network has more interactions than expected
#[derive(Debug, Clone, Parser)]
#[builder]
#[derive(Debug, Clone, Parser, Builder)]
#[clap(next_help_heading = "STRING PPI Enrichment Arguments")]
pub struct StringPpiEnrichmentArgs {
/// List of genes to retrieve network for
Expand Down

0 comments on commit 932393e

Please sign in to comment.