//
// Copyright (c) 2020-2021 science+computing ag and other contributors
//
// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/
//
// SPDX-License-Identifier: EPL-2.0
//
use std::path::PathBuf;
use clap::crate_authors;
use clap::crate_version;
use clap::App;
use clap::Arg;
use clap::ArgGroup;
// Helper types to ship around stringly typed clap API.
pub const IDENT_DEPENDENCY_TYPE_BUILD: &str = "build";
pub const IDENT_DEPENDENCY_TYPE_RUNTIME: &str = "runtime";
pub fn cli<'a>() -> App<'a> {
App::new("butido")
.author(crate_authors!())
.version(crate_version!())
.about("Generic Build Orchestration System for building linux packages with docker")
.arg(Arg::new("hide_bars")
.required(false)
.multiple(false)
.long("hide-bars")
.about("Hide all progress bars")
)
.arg(Arg::new("database_host")
.required(false)
.multiple(false)
.long("db-url")
.value_name("HOST")
.about("Overwrite the database host set via configuration. Can also be overriden via environment, but this setting has presendence.")
)
.arg(Arg::new("database_port")
.required(false)
.multiple(false)
.long("db-port")
.value_name("PORT")
.about("Overwrite the database port set via configuration. Can also be overriden via environment, but this setting has presendence.")
)
.arg(Arg::new("database_user")
.required(false)
.multiple(false)
.long("db-user")
.value_name("USER")
.about("Overwrite the database user set via configuration. Can also be overriden via environment, but this setting has presendence.")
)
.arg(Arg::new("database_password")
.required(false)
.multiple(false)
.long("db-password")
.alias("db-pw")
.value_name("PASSWORD")
.about("Overwrite the database password set via configuration. Can also be overriden via environment, but this setting has presendence.")
)
.arg(Arg::new("database_name")
.required(false)
.multiple(false)
.long("db-name")
.value_name("NAME")
.about("Overwrite the database name set via configuration. Can also be overriden via environment, but this setting has presendence.")
)
.subcommand(App::new("generate-completions")
.version(crate_version!())
.about("Generate and print commandline completions")
.arg(Arg::new("shell")
.possible_values(&["bash", "elvish", "fish", "zsh"])
.default_value("bash")
.required(true)
.multiple(false)
.about("Shell to generate completions for")
)
)
.subcommand(App::new("db")
.version(crate_version!())
.about("Database CLI interface")
.subcommand(App::new("cli")
.version(crate_version!())
.about("Start a database CLI, if installed on the current host")
.long_about(indoc::indoc!(r#"
Starts a database shell on the configured database using one of the following
programs:
- psql
- pgcli
if installed.
"#))
.arg(Arg::new("tool")
.re