diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-20 23:16:21 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-20 23:23:29 +0000 |
| commit | 7b07fdd0b28efa4e0026075d6ff82d050383c9a2 (patch) | |
| tree | 538a1443b713731c3cc5956b49ea75c1a2f67e16 /src/bin/ngit/sub_commands | |
| parent | e50687b908e802c9f3328c9b57060b63bb5706c0 (diff) | |
show subcommand hint at top of `ngit repo` output before fetch
- print hint line immediately, before coordinate lookup and relay fetch
- users see available subcommands (init, edit, accept) without waiting
Diffstat (limited to 'src/bin/ngit/sub_commands')
| -rw-r--r-- | src/bin/ngit/sub_commands/repo/mod.rs | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/bin/ngit/sub_commands/repo/mod.rs b/src/bin/ngit/sub_commands/repo/mod.rs index b15afdb..97e2c2b 100644 --- a/src/bin/ngit/sub_commands/repo/mod.rs +++ b/src/bin/ngit/sub_commands/repo/mod.rs | |||
| @@ -23,7 +23,11 @@ use crate::{ | |||
| 23 | sub_commands::init, | 23 | sub_commands::init, |
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | pub async fn launch(cli_args: &Cli, repo_command: Option<&RepoCommands>, offline: bool) -> Result<()> { | 26 | pub async fn launch( |
| 27 | cli_args: &Cli, | ||
| 28 | repo_command: Option<&RepoCommands>, | ||
| 29 | offline: bool, | ||
| 30 | ) -> Result<()> { | ||
| 27 | match repo_command { | 31 | match repo_command { |
| 28 | Some(RepoCommands::Init(args) | RepoCommands::Edit(args)) => { | 32 | Some(RepoCommands::Init(args) | RepoCommands::Edit(args)) => { |
| 29 | init::launch(cli_args, args).await | 33 | init::launch(cli_args, args).await |
| @@ -57,6 +61,9 @@ async fn show_info(cli_args: &Cli, offline: bool) -> Result<()> { | |||
| 57 | .ok() | 61 | .ok() |
| 58 | .map(|(_, user_ref, _)| user_ref.public_key); | 62 | .map(|(_, user_ref, _)| user_ref.public_key); |
| 59 | 63 | ||
| 64 | println!("subcommands: init, edit, accept (run `ngit repo --help` for details)"); | ||
| 65 | println!(); | ||
| 66 | |||
| 60 | let repo_coordinate = (try_and_get_repo_coordinates_when_remote_unknown(&git_repo).await).ok(); | 67 | let repo_coordinate = (try_and_get_repo_coordinates_when_remote_unknown(&git_repo).await).ok(); |
| 61 | 68 | ||
| 62 | let Some(repo_coordinate) = repo_coordinate else { | 69 | let Some(repo_coordinate) = repo_coordinate else { |
| @@ -86,7 +93,13 @@ async fn show_info(cli_args: &Cli, offline: bool) -> Result<()> { | |||
| 86 | return Ok(()); | 93 | return Ok(()); |
| 87 | }; | 94 | }; |
| 88 | 95 | ||
| 89 | print_repo_info(&repo_ref, my_pubkey.as_ref(), &repo_coordinate, git_repo_path).await; | 96 | print_repo_info( |
| 97 | &repo_ref, | ||
| 98 | my_pubkey.as_ref(), | ||
| 99 | &repo_coordinate, | ||
| 100 | git_repo_path, | ||
| 101 | ) | ||
| 102 | .await; | ||
| 90 | Ok(()) | 103 | Ok(()) |
| 91 | } | 104 | } |
| 92 | 105 | ||
| @@ -274,7 +287,9 @@ async fn print_repo_info( | |||
| 274 | for server in &extra_git_servers { | 287 | for server in &extra_git_servers { |
| 275 | let short = get_short_git_server_name(server); | 288 | let short = get_short_git_server_name(server); |
| 276 | if multi_maintainer { | 289 | if multi_maintainer { |
| 277 | let owners = find_server_owners(repo_ref, server, coordinate, my_pubkey, git_repo_path).await; | 290 | let owners = |
| 291 | find_server_owners(repo_ref, server, coordinate, my_pubkey, git_repo_path) | ||
| 292 | .await; | ||
| 278 | if owners.is_empty() { | 293 | if owners.is_empty() { |
| 279 | println!(" {short}"); | 294 | println!(" {short}"); |
| 280 | } else { | 295 | } else { |
| @@ -300,8 +315,14 @@ async fn print_repo_info( | |||
| 300 | .trim_start_matches("ws://") | 315 | .trim_start_matches("ws://") |
| 301 | .trim_end_matches('/'); | 316 | .trim_end_matches('/'); |
| 302 | if multi_maintainer { | 317 | if multi_maintainer { |
| 303 | let owners = | 318 | let owners = find_relay_owners( |
| 304 | find_relay_owners(repo_ref, relay.as_str(), coordinate, my_pubkey, git_repo_path).await; | 319 | repo_ref, |
| 320 | relay.as_str(), | ||
| 321 | coordinate, | ||
| 322 | my_pubkey, | ||
| 323 | git_repo_path, | ||
| 324 | ) | ||
| 325 | .await; | ||
| 305 | if owners.is_empty() { | 326 | if owners.is_empty() { |
| 306 | println!(" {display}"); | 327 | println!(" {display}"); |
| 307 | } else { | 328 | } else { |
| @@ -328,7 +349,8 @@ async fn print_repo_info( | |||
| 328 | println!(); | 349 | println!(); |
| 329 | } | 350 | } |
| 330 | 351 | ||
| 331 | // --- Maintainer model note (only relevant when there are multiple maintainers) --- | 352 | // --- Maintainer model note (only relevant when there are multiple maintainers) |
| 353 | // --- | ||
| 332 | if multi_maintainer { | 354 | if multi_maintainer { |
| 333 | println!( | 355 | println!( |
| 334 | "{}", | 356 | "{}", |