diff --git a/Cargo.lock b/Cargo.lock index 04eb5c7..cdca5b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -97,6 +97,12 @@ dependencies = [ "objc2", ] +[[package]] +name = "bumpalo" +version = "3.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" + [[package]] name = "camino" version = "1.2.2" @@ -118,6 +124,7 @@ dependencies = [ "ctrlc", "dircpy", "fuzzy-matcher", + "indicatif", "itertools", "semver", "tempfile", @@ -250,6 +257,7 @@ dependencies = [ "encode_unicode", "libc", "once_cell", + "unicode-width", "windows-sys", ] @@ -373,6 +381,19 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "indicatif" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9375e112e4b463ec1b1c6c011953545c65a30164fbab5b581df32b3abf0dcb88" +dependencies = [ + "console", + "portable-atomic", + "unicode-width", + "unit-prefix", + "web-time", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.2" @@ -394,6 +415,16 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" +[[package]] +name = "js-sys" +version = "0.3.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -493,6 +524,12 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + [[package]] name = "proc-macro2" version = "1.0.106" @@ -530,6 +567,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + [[package]] name = "same-file" version = "1.0.6" @@ -743,6 +786,18 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "unit-prefix" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81e544489bf3d8ef66c953931f56617f423cd4b5494be343d9b9d3dda037b9a3" + [[package]] name = "utf8parse" version = "0.2.2" @@ -765,6 +820,61 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasm-bindgen" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi-util" version = "0.1.11" diff --git a/Cargo.toml b/Cargo.toml index 0f5dd6b..6054e65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,15 +15,23 @@ include = ["src/**/*", "LICENSE", "README.md", "Known-Features.toml"] [dependencies] color-eyre = "0.6.3" +ctrlc = "3.4.5" + cargo_metadata = "0.23.0" + clap = { version = "4.5.56", features = ["derive"] } clap_complete = "4.5.65" + console = { version = "0.16.1", features = ["std"], default-features = false } -ctrlc = "3.4.5" -fuzzy-matcher = "0.3.7" +indicatif = "0.18.3" + itertools = { version = "0.14.0", default-features = false, features = ["use_alloc"] } -semver = { version = "1.0.25", default-features = false } + toml_edit = "0.24.0" + +semver = { version = "1.0.25", default-features = false } +fuzzy-matcher = "0.3.7" + tempfile = { version = "3.20.0", default-features = false } dircpy = { version = "0.3.19", default-features = false } diff --git a/src/io/parsing/package.rs b/src/io/parsing/package.rs index 840763b..041ee07 100644 --- a/src/io/parsing/package.rs +++ b/src/io/parsing/package.rs @@ -1,4 +1,6 @@ use cargo_metadata::{CargoOpt, PackageId}; +use console::style; +use indicatif::ProgressBar; use crate::io::parsing::workspace::parse_workspace; use color_eyre::Result; @@ -11,13 +13,20 @@ use color_eyre::eyre::ContextCompat; use semver::VersionReq; use std::collections::HashMap; use std::path::PathBuf; +use std::time::Duration; pub fn get_packages(path: impl Into) -> Result<(Vec, Option, PathBuf)> { + let progress = ProgressBar::new_spinner() + .with_message(format!("running '{}'", style("cargo metadata").dim())); + progress.enable_steady_tick(Duration::from_millis(100)); + let metadata = cargo_metadata::MetadataCommand::new() .current_dir(path) .features(CargoOpt::AllFeatures) .exec()?; + progress.finish_and_clear(); + let metadata_packages: HashMap = metadata .packages .into_iter() diff --git a/src/prune/display.rs b/src/prune/display.rs index 1fd11aa..b5aa210 100644 --- a/src/prune/display.rs +++ b/src/prune/display.rs @@ -57,12 +57,6 @@ impl Display { } pub fn start(&self) -> Result<()> { - if self.is_terminal { - // clear for "Creating temporary project..." text - self.term.move_cursor_up(1)?; - self.term.clear_line()?; - } - writeln!(&self.term, "workspace [{}]", self.feature_count)?; if self.is_terminal { self.term.hide_cursor()?; diff --git a/src/prune/mod.rs b/src/prune/mod.rs index a4a6dcd..a497afc 100644 --- a/src/prune/mod.rs +++ b/src/prune/mod.rs @@ -7,11 +7,13 @@ use crate::{CleanLevel, PruneArgs}; use color_eyre::Result; use color_eyre::eyre::{ContextCompat, eyre}; use dircpy::copy_dir; +use indicatif::ProgressBar; use itertools::Itertools; use std::collections::HashMap; use std::ops::Not; use std::path::Path; use std::process::{Command, Stdio}; +use std::time::Duration; use tempfile::TempDir; @@ -33,11 +35,14 @@ pub fn prune(args: &PruneArgs) -> Result<()> { let mut document = if args.no_tmp { Document::new(".")? } else { - println!("Creating temporary project..."); - let project_path = tmp_dir.path(); + let progress = ProgressBar::new_spinner().with_message("Creating temporary project..."); + progress.enable_steady_tick(Duration::from_millis(100)); + let project_path = tmp_dir.path(); copy_dir(main_document.root_path(), project_path)?; + progress.finish_and_clear(); + match Document::new(project_path) { Ok(document) => {document} Err(err) => {