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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! Command line interface definition
use crate::{commands, config::Config};
use clap::{Parser, Subcommand};
/// Tidepool GVM - A high-performance Go Version Manager
#[derive(Parser, Debug)]
#[command(author, version, about = "A high-performance Go version management tool")]
pub struct Cli {
/// Verbose mode
#[arg(short, long, global = true)]
pub verbose: bool,
/// Quiet mode (only output errors)
#[arg(short, long, global = true)]
pub quiet: bool,
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
/// Install a specific Go version
Install {
/// The Go version to install (e.g., 1.21.3)
version: String,
/// Force re-installation
#[arg(short, long)]
force: bool,
},
/// Switch to a specific Go version
Use {
/// The Go version to use (e.g., 1.21.3)
version: String,
/// Set as global version
#[arg(short, long)]
global: bool,
},
/// Uninstall a specific Go version
Uninstall {
/// The Go version to uninstall (e.g., 1.21.3)
version: String,
},
/// List Go versions
List {
/// List all available remote versions
#[arg(short, long)]
all: bool,
},
/// Show the current Go version status
Status,
/// Show detailed information about a Go version
Info {
/// The Go version to show information for (e.g., 1.21.3)
version: String,
},
}
impl Cli {
pub async fn run(&self) -> anyhow::Result<()> {
let config = Config::new()?;
match &self.command {
Commands::Install { version, force } => {
commands::install(version, &config, *force).await
}
Commands::Use { version, global } => commands::switch(version, &config, *global, false),
Commands::Uninstall { version } => commands::uninstall(version, &config),
Commands::List { all } => commands::list(&config, *all),
Commands::Status => commands::status(&config),
Commands::Info { version } => commands::info(version, &config),
}
}
}