From 1dfd016821e9a3d33af75d9b3186f537f1bea417 Mon Sep 17 00:00:00 2001 From: Dr Griffith Rees Date: Fri, 5 Jul 2024 18:28:28 +0100 Subject: [PATCH] feat: add spinning progress UX for `DataCommand` and `MetricsCommand` --- Cargo.lock | 44 ++++++++++++++++++++++++++++++++++++++++++-- Cargo.toml | 1 + src/cli.rs | 17 +++++++++++++---- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 82a1490..54d0f99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -678,7 +678,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7" dependencies = [ "crossterm", - "strum", + "strum 0.26.2", "strum_macros 0.26.4", "unicode-width", ] @@ -1886,6 +1886,12 @@ dependencies = [ "libc", ] +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + [[package]] name = "memchr" version = "2.7.2" @@ -2712,7 +2718,8 @@ dependencies = [ "reqwest 0.12.4", "serde", "serde_json", - "strum", + "spinners", + "strum 0.26.2", "strum_macros 0.26.4", "thiserror", "tokio", @@ -3470,6 +3477,17 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "spinners" +version = "4.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0ef947f358b9c238923f764c72a4a9d42f2d637c46e059dbd319d6e7cfb4f82" +dependencies = [ + "lazy_static", + "maplit", + "strum 0.24.1", +] + [[package]] name = "sqlparser" version = "0.39.0" @@ -3544,12 +3562,34 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros 0.24.3", +] + [[package]] name = "strum" version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + [[package]] name = "strum_macros" version = "0.25.3" diff --git a/Cargo.toml b/Cargo.toml index ac76140..cf34740 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ itertools = "0.13.0" comfy-table = "7.1.1" thiserror = "1" nonempty = { version = "0.10.0", features = ["serialize"] } +spinners = "4.1.1" [features] diff --git a/src/cli.rs b/src/cli.rs index a47dd3d..b1da1f6 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -18,6 +18,7 @@ use popgetter::{ Popgetter, }; use serde::{Deserialize, Serialize}; +use spinners::{Spinner, Spinners}; use std::fs::File; use strum_macros::EnumString; @@ -86,12 +87,18 @@ impl RunCommand for DataCommand { async fn run(&self, config: Config) -> Result<()> { info!("Running `data` subcommand"); + let mut sp = Spinner::new( + Spinners::Dots9, + "Downloading and searching metadata from Azure".into(), + ); let popgetter = Popgetter::new_with_config(config).await?; + let search_results = popgetter.search(self.search_params_args.clone().into()); + + sp.stop(); - let mut data = popgetter - .search(self.search_params_args.clone().into()) - .download(&popgetter.config) - .await?; + let mut sp = Spinner::new(Spinners::Dots9, "Download Parquet files".into()); + let mut data = search_results.download(&popgetter.config).await?; + sp.stop(); debug!("{data:#?}"); @@ -259,8 +266,10 @@ impl RunCommand for MetricsCommand { info!("Running `metrics` subcommand"); debug!("{:#?}", self); + let mut sp = Spinner::new(Spinners::Dots9, "Downloading metadata from Azure".into()); let popgetter = Popgetter::new_with_config(config).await?; let search_results = popgetter.search(self.search_params_args.clone().into()); + sp.stop(); let len_requests = search_results.0.shape().0; println!("Found {} metrics.", len_requests);