From 92cdb5c1051eafd4cb33a71cb298687c9d46d1dd Mon Sep 17 00:00:00 2001 From: Dotan Nahum Date: Sun, 12 May 2024 16:41:21 +0300 Subject: [PATCH] tidy: tooling --- Cargo.lock | 1 + README.md | 2 +- release.toml | 1 + xtask/Cargo.toml | 1 + xtask/src/main.rs | 68 +++++++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 release.toml diff --git a/Cargo.lock b/Cargo.lock index dacdfdbb..75f742cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4173,6 +4173,7 @@ name = "xtask" version = "0.1.0" dependencies = [ "anyhow", + "clap 3.2.25", "xtaskops", ] diff --git a/README.md b/README.md index 670e7729..f968b793 100644 --- a/README.md +++ b/README.md @@ -316,7 +316,7 @@ Example format: # Providers -You can get a list of the providers and their described configuration values [in the documentation](https://docs.rs/teller). +You can get a list of the providers and their described configuration values [in the documentation](https://docs.rs/teller-providers/latest/teller_providers/providers/index.html). ### Testing check list: diff --git a/release.toml b/release.toml new file mode 100644 index 00000000..19f7e046 --- /dev/null +++ b/release.toml @@ -0,0 +1 @@ +tag-name = "v{{version}}" diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 0010a3a6..34efab01 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -7,5 +7,6 @@ edition = "2021" [dependencies] +clap = "3" xtaskops = "^0.4.1" anyhow = "1" diff --git a/xtask/src/main.rs b/xtask/src/main.rs index f8985b59..b380faf4 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -1,3 +1,67 @@ -fn main() -> Result<(), anyhow::Error> { - xtaskops::tasks::main() +use anyhow::{self, Context}; +/// main +/// +/// # Errors +/// +/// This function will return an error +pub fn main() -> anyhow::Result<()> { + use clap::{AppSettings, Arg, Command}; + let cli = Command::new("xtask") + .setting(AppSettings::SubcommandRequiredElseHelp) + .subcommand( + Command::new("coverage").arg( + Arg::new("dev") + .short('d') + .long("dev") + .help("generate an html report") + .takes_value(false), + ), + ) + .subcommand(Command::new("vars")) + .subcommand(Command::new("ci")) + .subcommand(Command::new("powerset")) + .subcommand( + Command::new("bloat-deps").arg( + Arg::new("package") + .short('p') + .long("package") + .help("package to build") + .required(true) + .takes_value(true), + ), + ) + .subcommand( + Command::new("bloat-time").arg( + Arg::new("package") + .short('p') + .long("package") + .help("package to build") + .required(true) + .takes_value(true), + ), + ) + .subcommand(Command::new("docs")); + let matches = cli.get_matches(); + + let root = xtaskops::ops::root_dir(); + let res = match matches.subcommand() { + Some(("coverage", sm)) => xtaskops::tasks::coverage(sm.is_present("dev")), + Some(("vars", _)) => { + println!("root: {root:?}"); + Ok(()) + } + Some(("ci", _)) => xtaskops::tasks::ci(), + Some(("docs", _)) => xtaskops::tasks::docs(), + Some(("powerset", _)) => xtaskops::tasks::powerset(), + Some(("bloat-deps", sm)) => xtaskops::tasks::bloat_deps( + sm.get_one::("package") + .context("please provide a package with -p")?, + ), + Some(("bloat-time", sm)) => xtaskops::tasks::bloat_time( + sm.get_one::("package") + .context("please provide a package with -p")?, + ), + _ => unreachable!("unreachable branch"), + }; + res }