git_side/commands/
remote.rs1use colored::Colorize;
2
3use crate::error::Result;
4use crate::side_repo::SideRepo;
5
6pub fn run(args: &[String]) -> Result<()> {
12 let repo = SideRepo::open()?;
13 repo.ensure_initialized()?;
14
15 if args.is_empty() {
16 let output = repo.git(&["remote", "-v"])?;
18 if output.is_empty() {
19 println!("{}", "No remotes configured.".yellow());
20 } else {
21 println!("{output}");
22 }
23 } else {
24 let args_refs: Vec<&str> = std::iter::once("remote")
26 .chain(args.iter().map(String::as_str))
27 .collect();
28 let output = repo.git(&args_refs)?;
29 if !output.is_empty() {
30 println!("{output}");
31 }
32
33 if args.first().is_some_and(|a| a == "add") {
35 println!("{} Remote added.", "Done.".green().bold());
36 } else if args.first().is_some_and(|a| a == "remove" || a == "rm") {
37 println!("{} Remote removed.", "Done.".green().bold());
38 }
39 }
40
41 Ok(())
42}