wash_cli/common/
scale_cmd.rs1use anyhow::Result;
2
3use wash_lib::cli::{
4 scale::{handle_scale_component, ScaleCommand},
5 CommandOutput, OutputKind,
6};
7
8use crate::appearance::spinner::Spinner;
9
10pub async fn handle_command(
11 command: ScaleCommand,
12 output_kind: OutputKind,
13) -> Result<CommandOutput> {
14 let sp: Spinner = Spinner::new(&output_kind)?;
15 let out = match command {
16 ScaleCommand::Component(cmd) => {
17 let scale_msg = if cmd.max_instances == u32::MAX {
18 "unbounded concurrency".to_string()
19 } else {
20 format!("{} max concurrent instances", cmd.max_instances)
21 };
22 sp.update_spinner_message(format!(
23 " Sending request to scale component {} to {scale_msg} ... ",
24 cmd.component_ref
25 ));
26 handle_scale_component(cmd.clone()).await?
27 }
28 };
29
30 sp.finish_and_clear();
31
32 Ok(out)
33}