diff --git a/Cargo.lock b/Cargo.lock index cc962bfc7..d56101e4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,12 +46,6 @@ dependencies = [ "libc", ] -[[package]] -name = "ansi_term" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30275ad0ad84ec1c06dde3b3f7d23c6006b7d76d61a85e7060b426b747eff70d" - [[package]] name = "any_ascii" version = "0.1.7" @@ -878,16 +872,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "dirs" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" -dependencies = [ - "cfg-if 0.1.10", - "dirs-sys", -] - [[package]] name = "dirs" version = "4.0.0" @@ -1879,6 +1863,12 @@ dependencies = [ "syn", ] +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + [[package]] name = "matchers" version = "0.1.0" @@ -2309,7 +2299,7 @@ dependencies = [ "csv", "encode_unicode 1.0.0", "lazy_static", - "term 0.7.0", + "term", "unicode-width", ] @@ -3098,13 +3088,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] -name = "spinner" -version = "0.5.0" +name = "spinoff" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e3a7cd01625b7e43e62815677d692cb59b221c2fdc2853d1eb86a260ee0c272" +checksum = "812db6f40551bdcdb10e1d2070ec33f69805d2bfb7e59426c7d14e7e1b4194dd" dependencies = [ - "ansi_term", - "term 0.6.1", + "colored 2.0.0", + "maplit", + "once_cell", + "strum", ] [[package]] @@ -3177,6 +3169,28 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck 0.4.0", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + [[package]] name = "subtle" version = "2.4.1" @@ -3241,16 +3255,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "term" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0863a3345e70f61d613eab32ee046ccd1bcc5f9105fe402c61fcd0c13eeb8b5" -dependencies = [ - "dirs 2.0.2", - "winapi", -] - [[package]] name = "term" version = "0.7.0" @@ -3316,7 +3320,7 @@ dependencies = [ "getopts", "libc", "num_cpus", - "term 0.7.0", + "term", ] [[package]] @@ -4019,7 +4023,7 @@ dependencies = [ "clap 3.2.23", "colored 2.0.0", "dialoguer", - "dirs 4.0.0", + "dirs", "distance", "fern", "http_req", @@ -4032,7 +4036,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "spinner", + "spinoff", "target-lexicon 0.12.5", "tempdir", "tempfile", @@ -4260,7 +4264,7 @@ name = "wasmer-registry" version = "3.0.1" dependencies = [ "anyhow", - "dirs 4.0.0", + "dirs", "flate2", "futures-util", "graphql_client", diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index 40d5e2f8e..a137bd37b 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -43,7 +43,7 @@ wasmer-vfs = { version = "=3.0.1", path = "../vfs", default-features = false, f atty = "0.2" colored = "2.0" anyhow = "1.0" -spinner = "0.5.0" +spinoff = "0.5.4" clap = { version = "3.2.22", features = ["derive", "env"] } # For the function names autosuggestion distance = "0.4" @@ -166,6 +166,9 @@ http = [ "serde", ] +[target.'cfg(target_os = "windows")'.dependencies] +colored = "2.0.0" + [package.metadata.binstall] pkg-fmt = "tgz" diff --git a/lib/cli/src/commands/run.rs b/lib/cli/src/commands/run.rs index c3de8add8..cc854f086 100644 --- a/lib/cli/src/commands/run.rs +++ b/lib/cli/src/commands/run.rs @@ -645,17 +645,20 @@ impl Run { } } -fn start_spinner(msg: String) -> Option { +fn start_spinner(msg: String) -> Option { if !isatty::stdout_isatty() { return None; } - Some( - spinner::SpinnerBuilder::new(msg) - .spinner(vec![ - "⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷", " ", "⠁", "⠂", "⠄", "⡀", "⢀", "⠠", "⠐", "⠈", - ]) - .start(), - ) + #[cfg(target_os = "windows")] + { + use colored::control; + let _ = control::enable_virtual_terminal(true); + } + Some(spinoff::Spinner::new( + spinoff::Spinners::Dots, + msg, + spinoff::Color::White, + )) } /// Before looking up a command from the registry, try to see if we have @@ -706,8 +709,7 @@ pub(crate) fn try_autoinstall_package( force_install, ); if let Some(sp) = sp.take() { - sp.close(); - print!("\r"); + sp.clear(); } let _ = std::io::stdout().flush(); let (_, package_dir) = match result { @@ -765,8 +767,8 @@ fn try_lookup_command(sv: &mut SplitVersion) -> Result Result anyhow::Result<()> { Ok(()) } - // Test that changes to wapm run don't break wasmer run #[test] fn test_wapm_run_works() -> anyhow::Result<()> { - let output = Command::new("wapm") - .arg("install") - .arg("cowsay") - .output()?; + let output = Command::new("wapm").arg("install").arg("cowsay").output()?; if !output.status.success() { bail!( @@ -570,7 +566,10 @@ fn test_wapm_run_works() -> anyhow::Result<()> { .arg("run") .arg("cowsay") .arg("hello") - .env("WAPM_RUNTIME".to_string(), format!("{}", get_wasmer_path().display())) + .env( + "WAPM_RUNTIME".to_string(), + format!("{}", get_wasmer_path().display()), + ) .output()?; if !output.status.success() {