diff options
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/git_remote_nostr/main.rs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/bin/git_remote_nostr/main.rs b/src/bin/git_remote_nostr/main.rs index f793a0c..ed9fe9d 100644 --- a/src/bin/git_remote_nostr/main.rs +++ b/src/bin/git_remote_nostr/main.rs | |||
| @@ -134,18 +134,27 @@ fn process_args() -> Result<Option<(NostrUrlDecoded, Repo)>> { | |||
| 134 | let args = env::args(); | 134 | let args = env::args(); |
| 135 | let args = args.skip(1).take(2).collect::<Vec<_>>(); | 135 | let args = args.skip(1).take(2).collect::<Vec<_>>(); |
| 136 | 136 | ||
| 137 | let ([_, nostr_remote_url] | [nostr_remote_url]) = args.as_slice() else { | ||
| 138 | bail!("invalid arguments - no url"); | ||
| 139 | }; | ||
| 140 | let decoded_nostr_url = | ||
| 141 | NostrUrlDecoded::from_str(nostr_remote_url).context("invalid nostr url")?; | ||
| 142 | |||
| 143 | if env::args().nth(1).as_deref() == Some("--version") { | 137 | if env::args().nth(1).as_deref() == Some("--version") { |
| 144 | const VERSION: &str = env!("CARGO_PKG_VERSION"); | 138 | const VERSION: &str = env!("CARGO_PKG_VERSION"); |
| 145 | println!("v{VERSION}"); | 139 | println!("v{VERSION}"); |
| 146 | return Ok(None); | 140 | return Ok(None); |
| 147 | } | 141 | } |
| 148 | 142 | ||
| 143 | let ([_, nostr_remote_url] | [nostr_remote_url]) = args.as_slice() else { | ||
| 144 | println!("nostr plugin for git"); | ||
| 145 | println!("Usage:"); | ||
| 146 | println!( | ||
| 147 | " - add a nostr repository as a remote by using the url format nostr://pub123/identifier" | ||
| 148 | ); | ||
| 149 | println!(" - remote branches begining with `pr/` are PRs from contributors"); | ||
| 150 | println!(" - to open a PR, push a branch with the prefix `pr/`"); | ||
| 151 | println!(" - branches with this prefix are issued by the maintainer(s)"); | ||
| 152 | return Ok(None); | ||
| 153 | }; | ||
| 154 | |||
| 155 | let decoded_nostr_url = | ||
| 156 | NostrUrlDecoded::from_str(nostr_remote_url).context("invalid nostr url")?; | ||
| 157 | |||
| 149 | let git_repo = Repo::from_path(&PathBuf::from( | 158 | let git_repo = Repo::from_path(&PathBuf::from( |
| 150 | std::env::var("GIT_DIR").context("git should set GIT_DIR when remote helper is called")?, | 159 | std::env::var("GIT_DIR").context("git should set GIT_DIR when remote helper is called")?, |
| 151 | ))?; | 160 | ))?; |