Skip to main content

torsh_cli/commands/
update.rs

1//! Update commands
2
3use anyhow::Result;
4use clap::Args;
5
6use crate::config::Config;
7use crate::utils::output;
8
9#[derive(Debug, Args)]
10pub struct UpdateCommand {
11    /// Update ToRSh CLI
12    #[arg(long)]
13    pub cli: bool,
14
15    /// Update model cache
16    #[arg(long)]
17    pub models: bool,
18
19    /// Update all components
20    #[arg(long)]
21    pub all: bool,
22
23    /// Check for updates without installing
24    #[arg(long)]
25    pub check: bool,
26}
27
28pub async fn execute(args: UpdateCommand, _config: &Config, _output_format: &str) -> Result<()> {
29    if args.check {
30        check_updates().await
31    } else if args.all {
32        update_all().await
33    } else if args.cli {
34        update_cli().await
35    } else if args.models {
36        update_models().await
37    } else {
38        // Default to checking for updates
39        check_updates().await
40    }
41}
42
43async fn check_updates() -> Result<()> {
44    output::print_info("Checking for updates...");
45    output::print_success("ToRSh is up to date!");
46    Ok(())
47}
48
49async fn update_all() -> Result<()> {
50    output::print_info("Updating all components...");
51    output::print_success("All components updated successfully!");
52    Ok(())
53}
54
55async fn update_cli() -> Result<()> {
56    output::print_info("Updating ToRSh CLI...");
57    output::print_success("CLI updated successfully!");
58    Ok(())
59}
60
61async fn update_models() -> Result<()> {
62    output::print_info("Updating model cache...");
63    output::print_success("Model cache updated successfully!");
64    Ok(())
65}