From ba2f301e946ee9192229ff67ac9cb6dc90e162d2 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 26 Nov 2020 14:50:29 +0100 Subject: Update dependency: clap: 3.0.0-beta.1 -> 3.0.0-beta.2 Signed-off-by: Matthias Beyer --- src/cli.rs | 165 ++++++++++++++++++++-------------------- src/commands/build.rs | 2 +- src/commands/db.rs | 18 ++--- src/commands/dependencies_of.rs | 2 +- src/commands/env_of.rs | 2 +- src/commands/find_pkg.rs | 2 +- src/commands/source.rs | 13 ++-- src/commands/util.rs | 2 +- src/commands/versions_of.rs | 2 +- src/commands/what_depends.rs | 2 +- src/db/connection.rs | 2 +- src/main.rs | 19 ++--- 12 files changed, 116 insertions(+), 115 deletions(-) (limited to 'src') diff --git a/src/cli.rs b/src/cli.rs index 6cffb76..30c6cae 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,6 +1,5 @@ use std::path::PathBuf; -use clap_v3 as clap; use clap::App; use clap::Arg; use clap::crate_authors; @@ -18,48 +17,48 @@ pub fn cli<'a>() -> App<'a> { .version(crate_version!()) .about("Generic Build Orchestration System for building linux packages with docker") - .arg(Arg::with_name("hide_bars") + .arg(Arg::new("hide_bars") .required(false) .multiple(false) .long("hide-bars") - .help("Hide all progress bars") + .about("Hide all progress bars") ) - .arg(Arg::with_name("database_host") + .arg(Arg::new("database_host") .required(false) .multiple(false) .long("db-url") .value_name("HOST") - .help("Overwrite the database host set via configuration. Can also be overriden via environment, but this setting has presendence.") + .about("Overwrite the database host set via configuration. Can also be overriden via environment, but this setting has presendence.") ) - .arg(Arg::with_name("database_port") + .arg(Arg::new("database_port") .required(false) .multiple(false) .long("db-port") .value_name("PORT") - .help("Overwrite the database port set via configuration. Can also be overriden via environment, but this setting has presendence.") + .about("Overwrite the database port set via configuration. Can also be overriden via environment, but this setting has presendence.") ) - .arg(Arg::with_name("database_user") + .arg(Arg::new("database_user") .required(false) .multiple(false) .long("db-user") .value_name("USER") - .help("Overwrite the database user set via configuration. Can also be overriden via environment, but this setting has presendence.") + .about("Overwrite the database user set via configuration. Can also be overriden via environment, but this setting has presendence.") ) - .arg(Arg::with_name("database_password") + .arg(Arg::new("database_password") .required(false) .multiple(false) .long("db-password") .alias("db-pw") .value_name("PASSWORD") - .help("Overwrite the database password set via configuration. Can also be overriden via environment, but this setting has presendence.") + .about("Overwrite the database password set via configuration. Can also be overriden via environment, but this setting has presendence.") ) - .arg(Arg::with_name("database_name") + .arg(Arg::new("database_name") .required(false) .multiple(false) .long("db-name") .value_name("NAME") - .help("Overwrite the database name set via configuration. Can also be overriden via environment, but this setting has presendence.") + .about("Overwrite the database name set via configuration. Can also be overriden via environment, but this setting has presendence.") ) .subcommand(App::new("db") @@ -75,130 +74,130 @@ pub fn cli<'a>() -> App<'a> { if installed. "#)) - .arg(Arg::with_name("tool") + .arg(Arg::new("tool") .required(false) .multiple(false) .long("tool") .value_name("TOOL") .possible_values(&["psql", "pgcli"]) - .help("Use a specific tool") + .about("Use a specific tool") ) ) .subcommand(App::new("artifacts") .about("List artifacts from the DB") - .arg(Arg::with_name("csv") + .arg(Arg::new("csv") .required(false) .multiple(false) .long("csv") .takes_value(false) - .help("Format output as CSV") + .about("Format output as CSV") ) ) .subcommand(App::new("envvars") .about("List envvars from the DB") - .arg(Arg::with_name("csv") + .arg(Arg::new("csv") .required(false) .multiple(false) .long("csv") .takes_value(false) - .help("Format output as CSV") + .about("Format output as CSV") ) ) .subcommand(App::new("images") .about("List images from the DB") - .arg(Arg::with_name("csv") + .arg(Arg::new("csv") .required(false) .multiple(false) .long("csv") .takes_value(false) - .help("Format output as CSV") + .about("Format output as CSV") ) ) .subcommand(App::new("submits") .about("List submits from the DB") - .arg(Arg::with_name("csv") + .arg(Arg::new("csv") .required(false) .multiple(false) .long("csv") .takes_value(false) - .help("Format output as CSV") + .about("Format output as CSV") ) ) .subcommand(App::new("jobs") .about("List jobs from the DB") - .arg(Arg::with_name("csv") + .arg(Arg::new("csv") .required(false) .multiple(false) .long("csv") .takes_value(false) - .help("Format output as CSV") + .about("Format output as CSV") ) - .arg(Arg::with_name("submit_uuid") + .arg(Arg::new("submit_uuid") .required(false) .multiple(false) .long("of-submit") .short('S') .takes_value(true) .value_name("UUID") - .help("Only list jobs of a certain submit") + .about("Only list jobs of a certain submit") ) ) .subcommand(App::new("job") .about("Show a specific job from the DB") - .arg(Arg::with_name("csv") + .arg(Arg::new("csv") .required(false) .multiple(false) .long("csv") .takes_value(false) - .help("Format output as CSV") + .about("Format output as CSV") ) - .arg(Arg::with_name("job_uuid") + .arg(Arg::new("job_uuid") .required(true) .multiple(false) .index(1) .takes_value(true) .value_name("UUID") - .help("The job to show") + .about("The job to show") ) - .arg(Arg::with_name("show_log") + .arg(Arg::new("show_log") .required(false) .multiple(false) .long("log") .short('L') - .help("Show the log") + .about("Show the log") ) - .arg(Arg::with_name("show_script") + .arg(Arg::new("show_script") .required(false) .multiple(false) .long("script") .short('s') - .help("Show the script") + .about("Show the script") ) - .arg(Arg::with_name("show_env") + .arg(Arg::new("show_env") .required(false) .multiple(false) .long("env") .short('E') - .help("Show the environment of the job") + .about("Show the environment of the job") ) - .arg(Arg::with_name("script_disable_highlighting") + .arg(Arg::new("script_disable_highlighting") .required(false) .multiple(false) .long("disable-highlighting") .short('H') - .help("Disable highlighting when showing the script") + .about("Disable highlighting when showing the script") ) ) @@ -207,64 +206,64 @@ pub fn cli<'a>() -> App<'a> { .subcommand(App::new("build") .about("Build packages in containers") - .arg(Arg::with_name("package_name") + .arg(Arg::new("package_name") .required(true) .multiple(false) .index(1) ) - .arg(Arg::with_name("package_version") + .arg(Arg::new("package_version") .required(false) .multiple(false) .index(2) ) - .arg(Arg::with_name("staging_dir") + .arg(Arg::new("staging_dir") .required(false) .multiple(false) .long("staging-dir") .takes_value(true) .value_name("PATH") .validator(dir_exists_validator) - .help("Do not throw dice on staging directory name, but hardcode for this run.") + .about("Do not throw dice on staging directory name, but hardcode for this run.") ) - .arg(Arg::with_name("env") + .arg(Arg::new("env") .required(false) .multiple(true) .short('E') .long("env") .validator(env_pass_validator) - .help("Pass these variables to each build job (expects \"key=value\" or name of variable available in ENV)") + .about("Pass these variables to each build job (expects \"key=value\" or name of variable available in ENV)") ) - .arg(Arg::with_name("image") + .arg(Arg::new("image") .required(true) .multiple(false) .takes_value(true) .value_name("IMAGE NAME") .short('I') .long("image") - .help("Name of the docker image to use") + .about("Name of the docker image to use") ) - .arg(Arg::with_name("write-log-file") + .arg(Arg::new("write-log-file") .required(false) .multiple(false) .long("write-log") .short('L') - .help("Write the log not only to database, but also in a plain-text-file") + .about("Write the log not only to database, but also in a plain-text-file") ) ) .subcommand(App::new("what-depends") .about("List all packages that depend on a specific package") - .arg(Arg::with_name("package_name") + .arg(Arg::new("package_name") .required(true) .multiple(false) .index(1) - .help("The name of the package") + .about("The name of the package") ) - .arg(Arg::with_name("dependency_type") + .arg(Arg::new("dependency_type") .required(false) .multiple(true) .takes_value(true) @@ -283,27 +282,27 @@ pub fn cli<'a>() -> App<'a> { IDENT_DEPENDENCY_TYPE_BUILD, IDENT_DEPENDENCY_TYPE_RUNTIME, ]) - .help("Specify which dependency types are to be checked. By default, all are checked") + .about("Specify which dependency types are to be checked. By default, all are checked") ) ) .subcommand(App::new("dependencies-of") .alias("depsof") .about("List the depenendcies of a package") - .arg(Arg::with_name("package_name") + .arg(Arg::new("package_name") .required(true) .multiple(false) .index(1) .value_name("PACKAGE_NAME") - .help("The name of the package") + .about("The name of the package") ) - .arg(Arg::with_name("package_version_constraint") + .arg(Arg::new("package_version_constraint") .required(false) .multiple(false) .index(2) .value_name("VERSION_CONSTRAINT") - .help("A version constraint to search for (optional)") + .about("A version constraint to search for (optional)") ) - .arg(Arg::with_name("dependency_type") + .arg(Arg::new("dependency_type") .required(false) .multiple(true) .takes_value(true) @@ -322,72 +321,72 @@ pub fn cli<'a>() -> App<'a> { IDENT_DEPENDENCY_TYPE_BUILD, IDENT_DEPENDENCY_TYPE_RUNTIME, ]) - .help("Specify which dependency types are to be printed. By default, all are checked") + .about("Specify which dependency types are to be printed. By default, all are checked") ) ) .subcommand(App::new("versions-of") .alias("versions") .about("List the versions of a package") - .arg(Arg::with_name("package_name") + .arg(Arg::new("package_name") .required(true) .multiple(false) .index(1) .value_name("PACKAGE_NAME") - .help("The name of the package") + .about("The name of the package") ) ) .subcommand(App::new("env-of") .alias("env") .about("Show the ENV configured for a package") - .arg(Arg::with_name("package_name") + .arg(Arg::new("package_name") .required(true) .multiple(false) .index(1) .value_name("PACKAGE_NAME") - .help("The name of the package") + .about("The name of the package") ) - .arg(Arg::with_name("package_version_constraint") + .arg(Arg::new("package_version_constraint") .required(false) .multiple(false) .index(2) .value_name("VERSION_CONSTRAINT") - .help("A version constraint to search for (optional)") + .about("A version constraint to search for (optional)") ) ) .subcommand(App::new("find-pkg") .about("Find a package by regex") - .arg(Arg::with_name("package_name_regex") + .arg(Arg::new("package_name_regex") .required(true) .multiple(false) .index(1) .value_name("REGEX") - .help("The regex to match the package name against") + .about("The regex to match the package name against") ) - .arg(Arg::with_name("terse") + .arg(Arg::new("terse") .required(false) .multiple(false) .short('t') .long("terse") - .help("Do not use the fancy format, but simply ") + .about("Do not use the fancy format, but simply ") ) ) .subcommand(App::new("source") .about("Handle package sources") .subcommand(App::new("verify") .about("Hash-check all source files") - .arg(Arg::with_name("package_name") + .arg(Arg::new("package_name") .required(false) .multiple(false) .index(1) .value_name("PKG") - .help("Verify the sources of this package (optional, if left out, all packages are checked)") + .about("Verify the sources of this package (optional, if left out, all packages are checked)") ) - .arg(Arg::with_name("package_version") + .arg(Arg::new("package_version") .required(false) .multiple(false) .index(2) .value_name("VERSION") - .help("Verify the sources of this package version (optional, if left out, all packages are checked)") + .about("Verify the sources of this package version (optional, if left out, all packages are checked)") ) ) .subcommand(App::new("list-missing") @@ -395,36 +394,36 @@ pub fn cli<'a>() -> App<'a> { ) .subcommand(App::new("url") .about("Show the URL of the source of a package") - .arg(Arg::with_name("package_name") + .arg(Arg::new("package_name") .required(false) .multiple(false) .index(1) .value_name("PKG") - .help("Verify the sources of this package (optional, if left out, all packages are checked)") + .about("Verify the sources of this package (optional, if left out, all packages are checked)") ) - .arg(Arg::with_name("package_version") + .arg(Arg::new("package_version") .required(false) .multiple(false) .index(2) .value_name("VERSION") - .help("Verify the sources of this package version (optional, if left out, all packages are checked)") + .about("Verify the sources of this package version (optional, if left out, all packages are checked)") ) ) .subcommand(App::new("download") .about("Download the source for one or multiple packages") - .arg(Arg::with_name("package_name") + .arg(Arg::new("package_name") .required(false) .multiple(false) .index(1) .value_name("PKG") - .help("Verify the sources of this package (optional, if left out, all packages are checked)") + .about("Verify the sources of this package (optional, if left out, all packages are checked)") ) - .arg(Arg::with_name("package_version") + .arg(Arg::new("package_version") .required(false) .multiple(false) .index(2) .value_name("VERSION") - .help("Verify the sources of this package version (optional, if left out, all packages are checked)") + .about("Verify the sources of this package version (optional, if left out, all packages are checked)") ) ) ) @@ -434,7 +433,7 @@ pub fn cli<'a>() -> App<'a> { /// Naive check whether 's' is a 'key=value' pair or an existing environment variable /// /// TODO: Clean up this spaghetti code -fn env_pass_validator(s: String) -> Result<(), String> { +fn env_pass_validator(s: &str) -> Result<(), String> { let v = s.split("=").collect::>(); if v.len() != 2 { @@ -476,7 +475,7 @@ fn env_pass_validator(s: String) -> Result<(), String> { Ok(()) } -fn dir_exists_validator(s: String) -> Result<(), String> { +fn dir_exists_validator(s: &str) -> Result<(), String> { if PathBuf::from(&s).is_dir() { Ok(()) } else { diff --git a/src/commands/build.rs b/src/commands/build.rs index 122dd57..dac0f77 100644 --- a/src/commands/build.rs +++ b/src/commands/build.rs @@ -8,7 +8,7 @@ use anyhow::Context; use anyhow::Error; use anyhow::Result; use anyhow::anyhow; -use clap_v3::ArgMatches; +use clap::ArgMatches; use diesel::PgConnection; use logcrate::debug; use tokio::sync::RwLock; diff --git a/src/commands/db.rs b/src/commands/db.rs index ea9bb9a..f2a2d3d 100644 --- a/src/commands/db.rs +++ b/src/commands/db.rs @@ -2,7 +2,6 @@ use std::fmt::Display; use std::path::PathBuf; use std::process::Command; -use clap_v3 as clap; use anyhow::Context; use anyhow::Error; use anyhow::Result; @@ -26,14 +25,15 @@ use crate::log::LogItem; pub fn db<'a>(db_connection_config: DbConnectionConfig, config: &Configuration<'a>, matches: &ArgMatches) -> Result<()> { match matches.subcommand() { - ("cli", Some(matches)) => cli(db_connection_config, matches), - ("artifacts", Some(matches)) => artifacts(db_connection_config, matches), - ("envvars", Some(matches)) => envvars(db_connection_config, matches), - ("images", Some(matches)) => images(db_connection_config, matches), - ("submits", Some(matches)) => submits(db_connection_config, matches), - ("jobs", Some(matches)) => jobs(db_connection_config, matches), - ("job", Some(matches)) => job(db_connection_config, config, matches), - (other, _) => return Err(anyhow!("Unknown subcommand: {}", other)), + Some(("cli", matches)) => cli(db_connection_config, matches), + Some(("artifacts", matches)) => artifacts(db_connection_config, matches), + Some(("envvars", matches)) => envvars(db_connection_config, matches), + Some(("images", matches)) => images(db_connection_config, matches), + Some(("submits", matches)) => submits(db_connection_config, matches), + Some(("jobs", matches)) => jobs(db_connection_config, matches), + Some(("job", matches)) => job(db_connection_config, config, matches), + Some((other, _)) => return Err(anyhow!("Unknown subcommand: {}", other)), + None => return Err(anyhow!("No subcommand")), } } diff --git a/src/commands/dependencies_of.rs b/src/commands/dependencies_of.rs index 1efb15e..1addb94 100644 --- a/src/commands/dependencies_of.rs +++ b/src/commands/dependencies_of.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use clap_v3::ArgMatches; +use clap::ArgMatches; use crate::commands::util::getbool; use crate::config::*; diff --git a/src/commands/env_of.rs b/src/commands/env_of.rs index 4ce5161..9f2e667 100644 --- a/src/commands/env_of.rs +++ b/src/commands/env_of.rs @@ -1,7 +1,7 @@ use anyhow::Error; use anyhow::Context; use anyhow::Result; -use clap_v3::ArgMatches; +use clap::ArgMatches; use crate::package::PackageName; use crate::package::PackageVersionConstraint; diff --git a/src/commands/find_pkg.rs b/src/commands/find_pkg.rs index 1a84495..32f451d 100644 --- a/src/commands/find_pkg.rs +++ b/src/commands/find_pkg.rs @@ -1,7 +1,7 @@ use anyhow::Error; use anyhow::Context; use anyhow::Result; -use clap_v3::ArgMatches; +use clap::ArgMatches; use crate::config::Configuration; use crate::package::Package; diff --git a/src/commands/source.rs b/src/commands/source.rs index 2c40c81..81779b4 100644 --- a/src/commands/source.rs +++ b/src/commands/source.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; use anyhow::Error; use anyhow::Result; use anyhow::anyhow; -use clap_v3::ArgMatches; +use clap::ArgMatches; use tokio::stream::StreamExt; use tokio::io::AsyncWriteExt; use futures::TryStreamExt; @@ -18,11 +18,12 @@ use crate::util::progress::ProgressBars; pub async fn source<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo: Repository, progressbars: ProgressBars) -> Result<()> { match matches.subcommand() { - ("verify", Some(matches)) => verify(matches, config, repo).await, - ("list-missing", Some(matches)) => list_missing(matches, config, repo).await, - ("url", Some(matches)) => url(matches, config, repo).await, - ("download", Some(matches)) => download(matches, config, repo, progressbars).await, - (other, _) => return Err(anyhow!("Unknown subcommand: {}", other)), + Some(("verify", matches)) => verify(matches, config, repo).await, + Some(("list-missing", matches)) => list_missing(matches, config, repo).await, + Some(("url", matches)) => url(matches, config, repo).await, + Some(("download", matches)) => download(matches, config, repo, progressbars).await, + Some((other, _)) => return Err(anyhow!("Unknown subcommand: {}", other)), + None => return Err(anyhow!("No subcommand")), } } diff --git a/src/commands/util.rs b/src/commands/util.rs index bfc4829..9334320 100644 --- a/src/commands/util.rs +++ b/src/commands/util.rs @@ -1,4 +1,4 @@ -use clap_v3::ArgMatches; +use clap::ArgMatches; pub fn getbool(m: &ArgMatches, name: &str, cmp: &str) -> bool { // unwrap is safe here because clap is configured with default values diff --git a/src/commands/versions_of.rs b/src/commands/versions_of.rs index 6016122..940ded3 100644 --- a/src/commands/versions_of.rs +++ b/src/commands/versions_of.rs @@ -1,6 +1,6 @@ use anyhow::Error; use anyhow::Result; -use clap_v3::ArgMatches; +use clap::ArgMatches; use crate::package::PackageName; use crate::repository::Repository; diff --git a/src/commands/what_depends.rs b/src/commands/what_depends.rs index 5b3ef9c..268b543 100644 --- a/src/commands/what_depends.rs +++ b/src/commands/what_depends.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use clap_v3::ArgMatches; +use clap::ArgMatches; use resiter::Filter; use resiter::Map; diff --git a/src/db/connection.rs b/src/db/connection.rs index 20c73bc..33f5496 100644 --- a/src/db/connection.rs +++ b/src/db/connection.rs @@ -1,6 +1,6 @@ use anyhow::Error; use anyhow::Result; -use clap_v3::ArgMatches; +use clap::ArgMatches; use diesel::pg::PgConnection; use diesel::prelude::*; use getset::Getters; diff --git a/src/main.rs b/src/main.rs index b048c8f..5f812ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,49 +67,50 @@ async fn main() -> Result<()> { let db_connection_config = crate::db::parse_db_connection_config(&config, &cli); match cli.subcommand() { - ("db", Some(matches)) => crate::commands::db(db_connection_config, &config, matches)?, - ("build", Some(matches)) => { + Some(("db", matches)) => crate::commands::db(db_connection_config, &config, matches)?, + Some(("build", matches)) => { let conn = crate::db::establish_connection(db_connection_config)?; let repo = load_repo()?; crate::commands::build(matches, progressbars, conn, &config, repo, &repo_path, max_packages as u64).await? }, - ("what-depends", Some(matches)) => { + Some(("what-depends", matches)) => { let repo = load_repo()?; let bar = progressbars.what_depends(); bar.set_length(max_packages); crate::commands::what_depends(matches, &config, repo).await? }, - ("dependencies-of", Some(matches)) => { + Some(("dependencies-of", matches)) => { let repo = load_repo()?; let bar = progressbars.what_depends(); bar.set_length(max_packages); crate::commands::dependencies_of(matches, &config, repo).await? }, - ("versions-of", Some(matches)) => { + Some(("versions-of", matches)) => { let repo = load_repo()?; crate::commands::versions_of(matches, repo).await? }, - ("env-of", Some(matches)) => { + Some(("env-of", matches)) => { let repo = load_repo()?; crate::commands::env_of(matches, repo).await? }, - ("find-pkg", Some(matches)) => { + Some(("find-pkg", matches)) => { let repo = load_repo()?; crate::commands::find_pkg(matches, &config, repo).await? }, - ("source", Some(matches)) => { + Some(("source", matches)) => { let repo = load_repo()?; crate::commands::source(matches, &config, repo, progressbars).await? } - (other, _) => return Err(anyhow!("Unknown subcommand: {}", other)), + Some((other, _)) => return Err(anyhow!("Unknown subcommand: {}", other)), + None => return Err(anyhow!("No subcommand")), } Ok(()) -- cgit v1.2.3