diff --git a/src/cli.rs b/src/cli.rs index c8e1043..e2c87ff 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -68,6 +68,8 @@ For a sample configuration, see . // deprecated alias app = app.subcommand(command::eval::deprecated_alias()); + + register_command!(test_progress, app); } register_command!(apply, app); @@ -96,6 +98,8 @@ pub async fn run() { // deprecated alias handle_command!("introspect", eval, matches); + handle_command!("test-progress", test_progress, matches); + if let Some(args) = matches.subcommand_matches("gen-completions") { return gen_completions(args); } diff --git a/src/command/mod.rs b/src/command/mod.rs index 33c8ff7..2080cdb 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -5,3 +5,4 @@ pub mod apply_local; pub mod upload_keys; pub mod exec; pub mod nix_info; +pub mod test_progress; diff --git a/src/command/test_progress.rs b/src/command/test_progress.rs new file mode 100644 index 0000000..2a6751a --- /dev/null +++ b/src/command/test_progress.rs @@ -0,0 +1,24 @@ +use std::time::Duration; + +use clap::{App, AppSettings, SubCommand, ArgMatches}; +use tokio::time; + +use crate::progress::{Progress, OutputStyle}; + +pub fn subcommand() -> App<'static, 'static> { + SubCommand::with_name("test-progress") + .about("Run progress spinner tests") + .setting(AppSettings::Hidden) +} + +pub async fn run(_global_args: &ArgMatches<'_>, _local_args: &ArgMatches<'_>) { + let progress = Progress::with_style(OutputStyle::Condensed); + let mut task = progress.create_task_progress(String::from("test")); + + for i in 0..10 { + time::sleep(Duration::from_secs(2)).await; + task.log(&format!("Very slow counter: {}", i)); + } + + task.success("Completed"); +}