From 4a5c32ba062ca6ba7fd27e89d2b2f46e4f2368fb Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 1 Apr 2024 15:43:30 +0100 Subject: feat(init): support multiple git_servers in line with initial merged nip34 spec --- src/sub_commands/init.rs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'src/sub_commands') diff --git a/src/sub_commands/init.rs b/src/sub_commands/init.rs index 56129a6..4b35d28 100644 --- a/src/sub_commands/init.rs +++ b/src/sub_commands/init.rs @@ -25,7 +25,7 @@ pub struct SubCommandArgs { description: Option, #[clap(long)] /// git server url users can clone from - clone_url: Option, + clone_url: Vec, #[clap(short, long, value_parser, num_args = 1..)] /// homepage web: Vec, @@ -129,19 +129,24 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { )?, }; - let git_server = match &args.clone_url { - Some(t) => t.clone(), - None => Interactor::default().input( - PromptInputParms::default() - .with_prompt("clone url") - .with_default(if let Some(repo_ref) = &repo_ref { - repo_ref.git_server.clone() - } else if let Ok(git_repo) = git_repo.get_origin_url() { - git_repo - } else { - String::new() - }), - )?, + let git_server = if args.clone_url.is_empty() { + Interactor::default() + .input( + PromptInputParms::default() + .with_prompt("clone url") + .with_default(if let Some(repo_ref) = &repo_ref { + repo_ref.git_server.clone().join(" ") + } else if let Ok(git_repo) = git_repo.get_origin_url() { + git_repo + } else { + String::new() + }), + )? + .split(' ') + .map(std::string::ToString::to_string) + .collect() + } else { + args.clone_url.clone() }; let web: Vec = if args.web.is_empty() { -- cgit v1.2.3