diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-04-01 15:43:30 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-04-08 16:10:05 +0100 |
| commit | 4a5c32ba062ca6ba7fd27e89d2b2f46e4f2368fb (patch) | |
| tree | 47dac8fc609a34d088f01b825f3fa50cc14e55c0 /src/sub_commands/init.rs | |
| parent | 8c5a484a0e010eaa566c17acd8b344114b68caa6 (diff) | |
feat(init): support multiple git_servers
in line with initial merged nip34 spec
Diffstat (limited to 'src/sub_commands/init.rs')
| -rw-r--r-- | src/sub_commands/init.rs | 33 |
1 files changed, 19 insertions, 14 deletions
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 { | |||
| 25 | description: Option<String>, | 25 | description: Option<String>, |
| 26 | #[clap(long)] | 26 | #[clap(long)] |
| 27 | /// git server url users can clone from | 27 | /// git server url users can clone from |
| 28 | clone_url: Option<String>, | 28 | clone_url: Vec<String>, |
| 29 | #[clap(short, long, value_parser, num_args = 1..)] | 29 | #[clap(short, long, value_parser, num_args = 1..)] |
| 30 | /// homepage | 30 | /// homepage |
| 31 | web: Vec<String>, | 31 | web: Vec<String>, |
| @@ -129,19 +129,24 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 129 | )?, | 129 | )?, |
| 130 | }; | 130 | }; |
| 131 | 131 | ||
| 132 | let git_server = match &args.clone_url { | 132 | let git_server = if args.clone_url.is_empty() { |
| 133 | Some(t) => t.clone(), | 133 | Interactor::default() |
| 134 | None => Interactor::default().input( | 134 | .input( |
| 135 | PromptInputParms::default() | 135 | PromptInputParms::default() |
| 136 | .with_prompt("clone url") | 136 | .with_prompt("clone url") |
| 137 | .with_default(if let Some(repo_ref) = &repo_ref { | 137 | .with_default(if let Some(repo_ref) = &repo_ref { |
| 138 | repo_ref.git_server.clone() | 138 | repo_ref.git_server.clone().join(" ") |
| 139 | } else if let Ok(git_repo) = git_repo.get_origin_url() { | 139 | } else if let Ok(git_repo) = git_repo.get_origin_url() { |
| 140 | git_repo | 140 | git_repo |
| 141 | } else { | 141 | } else { |
| 142 | String::new() | 142 | String::new() |
| 143 | }), | 143 | }), |
| 144 | )?, | 144 | )? |
| 145 | .split(' ') | ||
| 146 | .map(std::string::ToString::to_string) | ||
| 147 | .collect() | ||
| 148 | } else { | ||
| 149 | args.clone_url.clone() | ||
| 145 | }; | 150 | }; |
| 146 | 151 | ||
| 147 | let web: Vec<String> = if args.web.is_empty() { | 152 | let web: Vec<String> = if args.web.is_empty() { |