diff options
Diffstat (limited to 'src/bin/git_remote_nostr/main.rs')
| -rw-r--r-- | src/bin/git_remote_nostr/main.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/bin/git_remote_nostr/main.rs b/src/bin/git_remote_nostr/main.rs index d7151d8..e57dff7 100644 --- a/src/bin/git_remote_nostr/main.rs +++ b/src/bin/git_remote_nostr/main.rs | |||
| @@ -24,6 +24,12 @@ use nostr::nips::nip19::Nip19Coordinate; | |||
| 24 | 24 | ||
| 25 | use crate::{client::Client, git::Repo}; | 25 | use crate::{client::Client, git::Repo}; |
| 26 | 26 | ||
| 27 | #[derive(Default, Clone)] | ||
| 28 | struct PushOptions { | ||
| 29 | title: Option<String>, | ||
| 30 | description: Option<String>, | ||
| 31 | } | ||
| 32 | |||
| 27 | mod fetch; | 33 | mod fetch; |
| 28 | mod list; | 34 | mod list; |
| 29 | mod push; | 35 | mod push; |
| @@ -71,6 +77,7 @@ async fn main() -> Result<()> { | |||
| 71 | let mut line = String::new(); | 77 | let mut line = String::new(); |
| 72 | 78 | ||
| 73 | let mut list_outputs = None; | 79 | let mut list_outputs = None; |
| 80 | let mut push_options: PushOptions = PushOptions::default(); | ||
| 74 | loop { | 81 | loop { |
| 75 | let tokens = read_line(&stdin, &mut line)?; | 82 | let tokens = read_line(&stdin, &mut line)?; |
| 76 | 83 | ||
| @@ -79,11 +86,23 @@ async fn main() -> Result<()> { | |||
| 79 | println!("option"); | 86 | println!("option"); |
| 80 | println!("push"); | 87 | println!("push"); |
| 81 | println!("fetch"); | 88 | println!("fetch"); |
| 89 | println!("push-options"); | ||
| 82 | println!(); | 90 | println!(); |
| 83 | } | 91 | } |
| 84 | ["option", "verbosity"] => { | 92 | ["option", "verbosity"] => { |
| 85 | println!("ok"); | 93 | println!("ok"); |
| 86 | } | 94 | } |
| 95 | ["option", "push-option", rest @ ..] => { | ||
| 96 | let option = rest.join(" "); | ||
| 97 | if let Some((key, value)) = option.split_once('=') { | ||
| 98 | match key { | ||
| 99 | "title" => push_options.title = Some(value.to_string()), | ||
| 100 | "description" => push_options.description = Some(value.to_string()), | ||
| 101 | _ => {} | ||
| 102 | } | ||
| 103 | } | ||
| 104 | println!("ok"); | ||
| 105 | } | ||
| 87 | ["option", ..] => { | 106 | ["option", ..] => { |
| 88 | println!("unsupported"); | 107 | println!("unsupported"); |
| 89 | } | 108 | } |
| @@ -98,8 +117,10 @@ async fn main() -> Result<()> { | |||
| 98 | refspec, | 117 | refspec, |
| 99 | &client, | 118 | &client, |
| 100 | list_outputs.clone(), | 119 | list_outputs.clone(), |
| 120 | push_options.title.as_ref().zip(push_options.description.as_ref()).map(|(t, d)| (t.clone(), d.clone())), | ||
| 101 | ) | 121 | ) |
| 102 | .await?; | 122 | .await?; |
| 123 | push_options = PushOptions::default(); | ||
| 103 | } | 124 | } |
| 104 | ["list"] => { | 125 | ["list"] => { |
| 105 | list_outputs = Some(list::run_list(&git_repo, &repo_ref, false).await?); | 126 | list_outputs = Some(list::run_list(&git_repo, &repo_ref, false).await?); |