diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-02-15 10:16:00 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-02-15 10:16:00 +0000 |
| commit | b7c24559aa2758820039295ac0f6120dfdec550e (patch) | |
| tree | 9d5fa8e1ea96bea6757232a9beea3e9add493ed3 /src/sub_commands | |
| parent | 6a4519b79cd36d1edbb492a3c98e2a3a0b42e0e9 (diff) | |
fix: allow optional description and web
also add a default web
Diffstat (limited to 'src/sub_commands')
| -rw-r--r-- | src/sub_commands/init.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/sub_commands/init.rs b/src/sub_commands/init.rs index 9fdcca5..3a0ff55 100644 --- a/src/sub_commands/init.rs +++ b/src/sub_commands/init.rs | |||
| @@ -43,6 +43,8 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 43 | let repo_config_result = get_repo_config_from_yaml(&git_repo); | 43 | let repo_config_result = get_repo_config_from_yaml(&git_repo); |
| 44 | // TODO: check for other claims | 44 | // TODO: check for other claims |
| 45 | 45 | ||
| 46 | let identifier = root_commit.to_string()[..7].to_string(); | ||
| 47 | |||
| 46 | let name = match &args.title { | 48 | let name = match &args.title { |
| 47 | Some(t) => t.clone(), | 49 | Some(t) => t.clone(), |
| 48 | None => Interactor::default().input(PromptInputParms::default().with_prompt("name"))?, | 50 | None => Interactor::default().input(PromptInputParms::default().with_prompt("name"))?, |
| @@ -50,8 +52,9 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 50 | 52 | ||
| 51 | let description = match &args.description { | 53 | let description = match &args.description { |
| 52 | Some(t) => t.clone(), | 54 | Some(t) => t.clone(), |
| 53 | None => Interactor::default() | 55 | None => { |
| 54 | .input(PromptInputParms::default().with_prompt("description (Optional)"))?, | 56 | Interactor::default().input(PromptInputParms::default().with_prompt("description"))? |
| 57 | } | ||
| 55 | }; | 58 | }; |
| 56 | 59 | ||
| 57 | let git_server = git_repo | 60 | let git_server = git_repo |
| @@ -63,7 +66,12 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 63 | 66 | ||
| 64 | let web: Vec<String> = if args.web.is_empty() { | 67 | let web: Vec<String> = if args.web.is_empty() { |
| 65 | Interactor::default() | 68 | Interactor::default() |
| 66 | .input(PromptInputParms::default().with_prompt("description (Optional)"))? | 69 | .input( |
| 70 | PromptInputParms::default() | ||
| 71 | .with_prompt("web") | ||
| 72 | .optional() | ||
| 73 | .with_default(format!("https://gitworkshop.dev/repo/{}", &identifier)), | ||
| 74 | )? | ||
| 67 | .split(' ') | 75 | .split(' ') |
| 68 | .map(std::string::ToString::to_string) | 76 | .map(std::string::ToString::to_string) |
| 69 | .collect() | 77 | .collect() |
| @@ -118,7 +126,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 118 | println!("publishing repostory reference..."); | 126 | println!("publishing repostory reference..."); |
| 119 | 127 | ||
| 120 | let repo_event = RepoRef { | 128 | let repo_event = RepoRef { |
| 121 | identifier: root_commit.to_string()[..7].to_string(), | 129 | identifier, |
| 122 | name, | 130 | name, |
| 123 | description, | 131 | description, |
| 124 | root_commit: root_commit.to_string(), | 132 | root_commit: root_commit.to_string(), |