diff --git a/src/main.rs b/src/main.rs index 71d7ab8..d7871e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 }) => { diff --git a/src/vcs.rs b/src/vcs.rs index f228d3f..5bab0e3 100644 --- a/src/vcs.rs +++ b/src/vcs.rs @@ -235,13 +235,13 @@ impl Vcs { }) } - pub fn set_branch( + pub fn checkout_ref( &mut self, - branch_name: &str, + ref_name: &str, projects: Option>, ) -> 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) }) } diff --git a/src/vcs/cli.rs b/src/vcs/cli.rs index e52841c..2a2946f 100644 --- a/src/vcs/cli.rs +++ b/src/vcs/cli.rs @@ -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>, + }, } #[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>, - }, -}