From b5a3f02a05311d5f5a4eb35b8d2513cb6a543560 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 10 May 2021 16:34:52 +0200 Subject: Add automatic pager setup This patch adds automatic pager setup in some of the subcommand implementations. The "build" subcommand is explicitely not added here. The setup is also done in a helper function to be able to alter the setup in one place. Signed-off-by: Matthias Beyer --- Cargo.toml | 1 + src/main.rs | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4eebeef..83db872 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,6 +47,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" diff --git a/src/main.rs b/src/main.rs index 45f587f..df78448 100644 --- a/src/main.rs +++ b/src/main.rs @@ -142,7 +142,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)?; @@ -162,6 +165,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")? @@ -169,6 +173,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")? @@ -176,6 +181,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")? @@ -183,6 +189,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")? @@ -190,6 +197,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 @@ -198,6 +206,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")? @@ -205,6 +214,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")? @@ -218,6 +228,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")? @@ -225,6 +236,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")? @@ -232,6 +244,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 @@ -239,6 +252,7 @@ async fn main() -> Result<()> { } Some(("endpoint", matches)) => { + setup_pager(); crate::commands::endpoint(matches, &config, progressbars) .await .context("endpoint command failed")? @@ -280,3 +294,9 @@ fn generate_completions(matches: &ArgMatches) { _ => unreachable!(), } } + +#[inline] +fn setup_pager() { + pager::Pager::new().setup(); +} + -- cgit v1.2.3 From 0acc1304b1568a9661a6c946281f0feb58541c4b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 10 May 2021 16:40:25 +0200 Subject: Add help text about environment functions Signed-off-by: Matthias Beyer --- src/cli.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cli.rs b/src/cli.rs index 4c629f8..db99b53 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -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) -- cgit v1.2.3