# tidepool-gvm
> π **Language**: [English](README.md) | [δΈζ](README.zh-CN.md)
A command-line interface for Go version management, providing an intuitive and user-friendly way to install, switch, and manage Go versions across platforms.
## Overview
`tidepool-gvm` is the CLI component of the Tidepool project that provides the `gvm` command. It's built on top of the `tidepool-version-manager` core library and offers a modern, package manager-style interface for Go version management.
## Installation
### Via Cargo
```bash
cargo install tidepool-gvm
```
This installs the binary as `gvm` command.
### From Source
```bash
git clone https://github.com/Slothtron/tidepool.git
cd tidepool
cargo build --release --package tidepool-gvm
```
The binary will be available at `target/release/gvm` (or `gvm.exe` on Windows).
## Usage
### Basic Commands
```bash
# Install and switch to a Go version
gvm install 1.21.3
# Force reinstall if version already exists
gvm install 1.21.3 --force
# List installed Go versions
gvm list
# List available versions for download
gvm list --available
# Show current Go version and environment
gvm status
# Show detailed information about a Go version
gvm info 1.21.3
# Uninstall a Go version
gvm uninstall 1.20.5
# Show help
gvm --help
```
### Command Details
#### Install Command
```bash
# Basic installation
gvm install <VERSION>
# Force reinstall (overwrite existing)
gvm install <VERSION> --force
gvm install <VERSION> -f
```
#### List Command
```bash
# List installed versions
gvm list
# Show available versions (not installed)
gvm list --available
gvm list -a
```
#### Other Commands
```bash
# Show current Go version and environment
gvm status
# Show detailed information about a version
gvm info <VERSION>
# Uninstall a version
gvm uninstall <VERSION>
```
## Features
- **π Version Management**: Install, switch, and uninstall Go versions
- **π Fast Operations**: Asynchronous downloads with progress display
- **π‘οΈ Safety**: Protection against accidental deletion of active versions
- **π Cross-Platform**: Works on Windows, macOS, and Linux
- **π¨ Modern UI**: Colorful terminal output and progress indicators
- **βοΈ Environment Management**: Automatic GOROOT, GOPATH, and PATH configuration
## Configuration
GVM stores configuration in platform-specific directories:
- **Windows**: `%APPDATA%\gvm\config.toml`
- **macOS/Linux**: `~/.config/gvm/config.toml`
### Example Configuration
```toml
[gvm]
install_dir = "/usr/local/go-versions"
download_dir = "/tmp/gvm-downloads"
mirror = "official"
cleanup_downloads = true
concurrent_connections = 4
```
## Environment Variables
After switching to a Go version, GVM automatically configures:
```bash
GOROOT="/usr/local/go-versions/1.21.3"
GOPATH="$HOME/go" # if not already set
PATH="$GOROOT/bin:$GOPATH/bin:$PATH"
```
## Development
This CLI tool is built using:
- **[clap](https://crates.io/crates/clap)**: Command-line argument parsing
- **[tokio](https://crates.io/crates/tokio)**: Async runtime
- **[indicatif](https://crates.io/crates/indicatif)**: Progress bars
- **[console](https://crates.io/crates/console)**: Terminal styling
- **[tidepool-version-manager](../../../crates/tidepool-version-manager/)**: Core functionality
### Project Structure
```
cli/tidepool-gvm/
βββ Cargo.toml # Package configuration
βββ src/
β βββ main.rs # Main entry point
β βββ lib.rs # Library interface
β βββ cli.rs # Command-line parsing
β βββ commands.rs # Command implementations
β βββ config.rs # Configuration management
β βββ ui.rs # User interface helpers
βββ examples/ # Usage examples
βββ tests/ # Integration tests
```
### Building
```bash
# Development build
cargo build --package tidepool-gvm
# Release build
cargo build --release --package tidepool-gvm
# Run tests
cargo test --package tidepool-gvm
# Run with debug logging
RUST_LOG=debug cargo run --package tidepool-gvm -- install 1.21.3
```
## Architecture
The CLI follows a clean architecture pattern:
1. **CLI Layer** (`cli.rs`): Parses command-line arguments using clap
2. **Command Layer** (`commands.rs`): Implements business logic for each command
3. **UI Layer** (`ui.rs`): Handles user interface and terminal output
4. **Config Layer** (`config.rs`): Manages application configuration
5. **Core Layer**: Uses `tidepool-version-manager` for actual version management
## Error Handling
The CLI provides user-friendly error messages and suggestions:
```bash
$ gvm use 1.21.3
β Go version 1.21.3 is not installed
π‘ Suggestions:
1. Install it first: gvm install 1.21.3
2. List available versions: gvm list --available
```
## License
This project is licensed under the MIT License. See [LICENSE](../../LICENSE) for details.
## Contributing
Contributions are welcome! Please see the main project's [Contributing Guide](../../CONTRIBUTING.md) for details.