summaryrefslogtreecommitdiffstats
path: root/src/cli.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs165
1 files changed, 82 insertions, 83 deletions
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 <name> <version>")
+ .about("Do not use the fancy format, but simply <name> <version>")
)
)
.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::<Vec<_>>();
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 {