refactor branch subcommand into checkout

master
Ales Katona 2 years ago
parent ea94a69502
commit a4da01ac39
Signed by: almindor
GPG Key ID: 2F773149BF38B48F

@ -23,8 +23,11 @@ fn main() {
};
match args.command {
Commands::Branch(BranchCommand::Set { branch, projects }) => {
vcs.set_branch(&branch, projects)
Commands::Checkout {
reference,
projects,
} => {
vcs.checkout_ref(&reference, projects)
.expect("Error setting branch on projects");
}
Commands::Profile(ProfileCommand::Save { profile }) => {

@ -235,13 +235,13 @@ impl Vcs {
})
}
pub fn set_branch(
pub fn checkout_ref(
&mut self,
branch_name: &str,
ref_name: &str,
projects: Option<Vec<String>>,
) -> Result<(), Error> {
self.set_projects_using(branch_name, projects, |project| {
project.repo.checkout(branch_name)
self.set_projects_using(ref_name, projects, |project| {
project.repo.checkout(ref_name)
})
}

@ -24,9 +24,14 @@ pub enum Commands {
/// Set or save profiles
#[clap(subcommand)]
Profile(ProfileCommand),
/// Set branch globally on workspace
#[clap(subcommand)]
Branch(BranchCommand),
/// Checkout specific repo reference (branch, commit etc.)
Checkout {
/// Reference name
reference: String,
/// Project list to apply checkout to, defaults to all
#[clap(short = 'p')]
projects: Option<Vec<String>>,
},
}
#[derive(Debug, Parser)]
@ -40,15 +45,3 @@ pub enum ProfileCommand {
/// Lists all saved profiles
List,
}
#[derive(Debug, Parser)]
pub enum BranchCommand {
/// Switch all projects in workspace to given branch
#[clap(arg_required_else_help = true)]
Set {
branch: String,
/// Project list, do any operation only on projects in this list (*comma separated*)
#[clap(short = 'p')]
projects: Option<Vec<String>>,
},
}

Loading…
Cancel
Save