wash_cli/common/
update_cmd.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use anyhow::Result;

use wash_lib::cli::{
    update::{handle_update_component, UpdateCommand},
    CommandOutput, OutputKind,
};

use crate::appearance::spinner::Spinner;

pub async fn handle_command(
    command: UpdateCommand,
    output_kind: OutputKind,
) -> Result<CommandOutput> {
    let sp: Spinner = Spinner::new(&output_kind)?;
    let out = match command {
        UpdateCommand::Component(cmd) => {
            sp.update_spinner_message(format!(
                " Updating Component {} to {} ... ",
                cmd.component_id, cmd.new_component_ref
            ));

            handle_update_component(cmd).await?
        }
    };

    sp.finish_and_clear();

    Ok(out)
}