summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-05-10 16:34:52 +0200
committerMatthias Beyer <matthias.beyer@atos.net>2021-05-10 16:34:56 +0200
commitb5a3f02a05311d5f5a4eb35b8d2513cb6a543560 (patch)
treef6d3a6c0d46cf67179269e4f4f4e0e5d4a2c528f /src/main.rs
parent1ebfa387fa5d47e3200b990f63f55bbe36adeff1 (diff)
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 <matthias.beyer@atos.net>
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs22
1 files changed, 21 insertions, 1 deletions
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();
+}
+