diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-05-11 09:05:16 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-05-11 09:05:16 +0200 |
commit | f4cd687ab7526276f767328c1e32717f018d9c84 (patch) | |
tree | fb1de39c2cb21e733ce6175a39908a2da36b0bbe | |
parent | 9c8c129650549e552211375f5ed01b50c4d40dde (diff) | |
parent | 0acc1304b1568a9661a6c946281f0feb58541c4b (diff) |
Merge branch 'auto-pager'
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/cli.rs | 8 | ||||
-rw-r--r-- | src/main.rs | 22 |
3 files changed, 30 insertions, 1 deletions
@@ -48,6 +48,7 @@ indoc = "1" itertools = "0.10" lazy_static = "1.4" log = "0.4" +pager = "0.16" parse-display = "0.4" pom = "3" ptree = "0.3" @@ -26,6 +26,14 @@ pub fn cli<'a>() -> App<'a> { .version(crate_version!()) .about("Generic Build Orchestration System for building linux packages with docker") + .after_help(r#" + The folowing environment variables can be passed to butido: + + RUST_LOG - to enable logging, for exact usage see the rust cookbook + PAGER - to change the pager + NOPAGER - to disable automatic use of the PAGER + "#) + .arg(Arg::new("hide_bars") .required(false) .multiple(false) diff --git a/src/main.rs b/src/main.rs index 807032f..8547375 100644 --- a/src/main.rs +++ b/src/main.rs @@ -149,7 +149,10 @@ async fn main() -> Result<()> { let db_connection_config = crate::db::parse_db_connection_config(&config, &cli); match cli.subcommand() { Some(("generate-completions", matches)) => generate_completions(matches), - Some(("db", matches)) => crate::commands::db(db_connection_config, &config, matches)?, + Some(("db", matches)) => { + setup_pager(); + crate::commands::db(db_connection_config, &config, matches)? + }, Some(("build", matches)) => { let conn = crate::db::establish_connection(db_connection_config)?; @@ -169,6 +172,7 @@ async fn main() -> Result<()> { } Some(("what-depends", matches)) => { let repo = load_repo()?; + setup_pager(); crate::commands::what_depends(matches, &config, repo) .await .context("what-depends command failed")? @@ -176,6 +180,7 @@ async fn main() -> Result<()> { Some(("dependencies-of", matches)) => { let repo = load_repo()?; + setup_pager(); crate::commands::dependencies_of(matches, &config, repo) .await .context("dependencies-of command failed")? @@ -183,6 +188,7 @@ async fn main() -> Result<()> { Some(("versions-of", matches)) => { let repo = load_repo()?; + setup_pager(); crate::commands::versions_of(matches, repo) .await .context("versions-of command failed")? @@ -190,6 +196,7 @@ async fn main() -> Result<()> { Some(("env-of", matches)) => { let repo = load_repo()?; + setup_pager(); crate::commands::env_of(matches, repo) .await .context("env-of command failed")? @@ -197,6 +204,7 @@ async fn main() -> Result<()> { Some(("find-artifact", matches)) => { let repo = load_repo()?; + setup_pager(); let conn = crate::db::establish_connection(db_connection_config)?; crate::commands::find_artifact(matches, &config, progressbars, repo, conn) .await @@ -205,6 +213,7 @@ async fn main() -> Result<()> { Some(("find-pkg", matches)) => { let repo = load_repo()?; + setup_pager(); crate::commands::find_pkg(matches, &config, repo) .await .context("find-pkg command failed")? @@ -212,6 +221,7 @@ async fn main() -> Result<()> { Some(("source", matches)) => { let repo = load_repo()?; + setup_pager(); crate::commands::source(matches, &config, repo, progressbars) .await .context("source command failed")? @@ -225,6 +235,7 @@ async fn main() -> Result<()> { Some(("lint", matches)) => { let repo = load_repo()?; + setup_pager(); crate::commands::lint(&repo_path, matches, progressbars, &config, repo) .await .context("lint command failed")? @@ -232,6 +243,7 @@ async fn main() -> Result<()> { Some(("tree-of", matches)) => { let repo = load_repo()?; + setup_pager(); crate::commands::tree_of(matches, repo, progressbars) .await .context("tree-of command failed")? @@ -239,6 +251,7 @@ async fn main() -> Result<()> { Some(("metrics", _)) => { let repo = load_repo()?; + setup_pager(); let conn = crate::db::establish_connection(db_connection_config)?; crate::commands::metrics(&repo_path, &config, repo, conn) .await @@ -246,6 +259,7 @@ async fn main() -> Result<()> { } Some(("endpoint", matches)) => { + setup_pager(); crate::commands::endpoint(matches, &config, progressbars) .await .context("endpoint command failed")? @@ -287,3 +301,9 @@ fn generate_completions(matches: &ArgMatches) { _ => unreachable!(), } } + +#[inline] +fn setup_pager() { + pager::Pager::new().setup(); +} + |