You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nenv/src/args.rs

77 lines
1.8 KiB
Rust

use std::ffi::OsString;
2 years ago
use crate::repository::NodeVersion;
2 years ago
use clap::{Parser, Subcommand};
#[derive(Clone, Debug, Parser)]
#[clap(infer_subcommands = true)]
pub struct Args {
/// Prints verbose logs
#[arg(long)]
pub verbose: bool,
2 years ago
#[command(subcommand)]
pub command: Command,
2 years ago
}
#[derive(Clone, Debug, Subcommand)]
pub enum Command {
/// Returns the nenv version
#[command(short_flag = 'v', aliases = &["--version"])]
Version,
/// Initializes nenv directories and installs a default node version
#[command()]
Init,
/// Installs the given node version
2 years ago
#[command()]
Install(InstallArgs),
/// Sets the specified version as the global default
2 years ago
#[command()]
Default(DefaultArgs),
2 years ago
/// Creates wrapper scripts for node binaries
/// so they can be found in the path and are executed
/// with the correct node version. This will delete
/// all binary wrappers that don't apply to the active node version.
#[command()]
RemapBinaries,
/// Lists all available versions
#[command(name = "list-versions")]
ListVersions,
/// Executes the given version specific node executable
#[command()]
Exec(ExecArgs),
2 years ago
/// Clears the download cache
2 years ago
#[command()]
ClearCache,
2 years ago
}
#[derive(Clone, Debug, Parser)]
pub struct ExecArgs {
/// The command to execute
2 years ago
#[arg()]
pub command: String,
/// The arguments for the command
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
pub args: Vec<OsString>,
}
#[derive(Clone, Debug, Parser)]
pub struct InstallArgs {
/// the version to install
pub version: NodeVersion,
2 years ago
}
#[derive(Clone, Debug, Parser)]
pub struct DefaultArgs {
/// The version to set as default
pub version: NodeVersion,
2 years ago
}