use crate::commands::{global::GlobalCommand, venv_cmd::VenvCommand};
use clap::{Parser, Subcommand, ValueEnum};
#[derive(ValueEnum, Clone, Debug)]
pub enum OutputFormat {
Table,
Json,
Yaml,
}
#[derive(Parser)]
#[command(name = "vx")]
#[command(about = "Universal version executor for development tools")]
#[command(version)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
#[arg(long, global = true)]
pub use_system_path: bool,
#[arg(short, long, global = true)]
pub verbose: bool,
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
pub args: Vec<String>,
}
#[derive(Subcommand, Clone)]
pub enum Commands {
Version,
#[command(alias = "ls")]
List {
tool: Option<String>,
#[arg(long)]
status: bool,
#[arg(long)]
installed: bool,
#[arg(long)]
available: bool,
},
#[command(alias = "i")]
Install {
tool: String,
version: Option<String>,
#[arg(long)]
force: bool,
},
#[command(alias = "up")]
Update {
tool: Option<String>,
#[arg(long)]
apply: bool,
},
#[command(name = "self-update")]
SelfUpdate {
#[arg(long)]
check: bool,
version: Option<String>,
#[arg(long)]
token: Option<String>,
#[arg(long)]
prerelease: bool,
#[arg(long)]
force: bool,
},
#[command(alias = "rm")]
Uninstall {
tool: String,
version: Option<String>,
#[arg(long)]
force: bool,
},
Which {
tool: String,
#[arg(long)]
all: bool,
},
Versions {
tool: String,
#[arg(long)]
latest: Option<usize>,
#[arg(long)]
prerelease: bool,
#[arg(long)]
detailed: bool,
#[arg(short, long)]
interactive: bool,
},
Switch {
tool_version: String,
#[arg(long)]
global: bool,
},
#[command(alias = "cfg")]
Config {
#[command(subcommand)]
command: Option<ConfigCommand>,
},
Search {
query: Option<String>,
#[arg(long)]
category: Option<String>,
#[arg(long)]
installed_only: bool,
#[arg(long)]
available_only: bool,
#[arg(long, value_enum, default_value = "table")]
format: OutputFormat,
#[arg(short, long)]
verbose: bool,
},
Sync {
#[arg(long)]
check: bool,
#[arg(long)]
force: bool,
#[arg(long)]
dry_run: bool,
#[arg(short, long)]
verbose: bool,
#[arg(long)]
no_parallel: bool,
#[arg(long)]
no_auto_install: bool,
},
Init {
#[arg(long)]
interactive: bool,
#[arg(long)]
template: Option<String>,
#[arg(long)]
tools: Option<String>,
#[arg(long)]
force: bool,
#[arg(long)]
dry_run: bool,
#[arg(long)]
list_templates: bool,
},
Clean {
#[arg(long)]
dry_run: bool,
#[arg(long)]
cache: bool,
#[arg(long)]
orphaned: bool,
#[arg(long)]
all: bool,
#[arg(long)]
force: bool,
#[arg(long)]
older_than: Option<u32>,
#[arg(short, long)]
verbose: bool,
},
Stats,
Plugin {
#[command(subcommand)]
command: PluginCommand,
},
Shell {
#[command(subcommand)]
command: ShellCommand,
},
Venv {
#[command(subcommand)]
command: VenvCommand,
},
Global {
#[command(subcommand)]
command: GlobalCommand,
},
}
#[derive(Subcommand, Clone)]
pub enum ConfigCommand {
Show,
Set {
key: String,
value: String,
},
Get {
key: String,
},
Reset {
key: Option<String>,
},
Edit,
}
#[derive(Subcommand, Clone)]
pub enum PluginCommand {
List {
#[arg(long)]
enabled: bool,
#[arg(long)]
category: Option<String>,
},
Info {
name: String,
},
Enable {
name: String,
},
Disable {
name: String,
},
Search {
query: String,
},
Stats,
}
#[derive(Subcommand, Clone)]
pub enum ShellCommand {
Init {
shell: Option<String>,
},
Completions {
shell: String,
},
}