use colored::Colorize;
use crate::{
branching::{Branch, BranchCommands},
cli::cli::VCS,
commands::branch::executors::{
execute_branch_breezy, execute_branch_git, execute_branch_mercurial,
},
diagnostics::{log_diagnostic, DiagnosticKind},
helpers::detect_vcs,
logging::helpers::bright_yellow_backtick,
};
pub fn process_branch_commands(branch_commands: Branch) {
match branch_commands.command {
Some(branch_command) => match branch_command {
BranchCommands::Rename(branch_rename_options) => {
}
_ => {
log_diagnostic(DiagnosticKind::WorkInProgress {
feature: "branching",
});
}
},
None => {
branch_command(branch_commands.info);
}
}
}
pub fn branch_command(info: bool) {
if info {
execute_branch_info();
} else {
execute_branch();
}
}
pub fn execute_branch_info() {
log_diagnostic(DiagnosticKind::ScudCommandInfo {
command: "branch",
description: "This command is used to list branches in both the local and \
remote repositories.",
});
log_diagnostic(DiagnosticKind::VCSInfo {
command_name: "branch",
git_command: &format!(
"{} {}",
"git branch -A",
"(along with other commands for more rich output)".bright_yellow()
),
mercurial_command: &format!(
"{} {}",
"hg branches",
"(along with other commands for more rich output)".bright_yellow()
),
breezy_command: &format!(
"{} {}",
"bzr branches",
"(along with other commands for more rich output)".bright_yellow()
),
});
}
pub fn execute_branch() {
let vcs = detect_vcs();
match vcs {
VCS::Git => execute_branch_git(),
VCS::Mercurial => execute_branch_mercurial(),
VCS::Breezy => execute_branch_breezy(),
}
log_diagnostic(DiagnosticKind::Tip {
body: &format!(
"{} {}{}{}{}{} {} {}{}{} {}{}{}",
"Use".yellow(),
bright_yellow_backtick(),
"scud branch create".green().italic(),
bright_yellow_backtick(),
" to ".yellow(),
"create a new local branch".bright_yellow(),
"or use".yellow(),
bright_yellow_backtick(),
"scud move".green().italic(),
bright_yellow_backtick(),
"to ".yellow(),
"move between branches".bright_yellow(),
" in the current local repository".yellow(),
),
});
}