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.

47 lines
1.2 KiB
Rust

3 years ago
use clap::Parser;
use std::path::PathBuf;
/// A fictional versioning CLI
#[derive(Debug, Parser)]
#[clap(name = "cargo-vcs")]
#[clap(about = "Version control helper for Cargo", long_about = None)]
pub struct Cli {
#[clap(subcommand)]
pub command: Commands,
/// Path to workspace folder, defaults to CWD
#[clap(short = 'p')]
pub path: Option<PathBuf>,
}
#[derive(Debug, Parser)]
pub enum Commands {
/// Show workspace status
Status {
#[clap(short = 'v')]
verbose: bool,
},
/// Set or save profiles
#[clap(subcommand)]
Profile(ProfileCommand),
/// Set branch globally on workspace
#[clap(subcommand)]
Branch(BranchCommand),
}
#[derive(Debug, Parser)]
pub enum ProfileCommand {
/// Save the current workspace VCS state to Cargo_vcs.toml under given profile name
#[clap(arg_required_else_help = true)]
Save { profile: String },
/// Switch workspace to given profile
#[clap(arg_required_else_help = true)]
Set { profile: String },
}
#[derive(Debug, Parser)]
pub enum BranchCommand {
/// Switch all projects in workspace to given branch
#[clap(arg_required_else_help = true)]
Set { branch: String },
}