feat(remote): add new remote

This commit is contained in:
grimhilt
2024-02-20 15:45:01 +01:00
parent 7719e27fe8
commit c6534cfd40
7 changed files with 112 additions and 3 deletions

View File

@@ -1,5 +1,4 @@
use clap::{App, Arg, SubCommand, ArgMatches};
use std::borrow::Cow;
use textwrap::{fill, Options};
use crate::commands::clone::{self, CloneArgs};

41
src/subcommands/remote.rs Normal file
View File

@@ -0,0 +1,41 @@
use clap::{App, Arg, SubCommand, ArgMatches};
use crate::commands;
use crate::commands::remote::RemoteArgs;
pub fn create() -> App<'static, 'static> {
SubCommand::with_name("remote")
.about("Manage set of tracked repositories")
.subcommand(
SubCommand::with_name("add")
.arg(
Arg::with_name("name")
.required(true)
.multiple(false)
.takes_value(true)
.value_name("NAME")
.help("The name of the remote"),
)
.arg(
Arg::with_name("url")
.required(true)
.multiple(false)
.takes_value(true)
.value_name("URL")
.help("The url of the remote"),
)
.about("Add a new remote to this repository")
)
}
pub fn handler(args: &ArgMatches<'_>) {
match args.subcommand() {
("add", Some(add_matches)) => {
commands::remote::remote_add(RemoteArgs {
name: add_matches.values_of("name"),
url: add_matches.values_of("url"),
});
}
_ => println!("Invalid or missing subcommand for 'remote'"),
}
}