aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/git-sugpatch.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/bin/git-sugpatch.rs b/src/bin/git-sugpatch.rs
new file mode 100644
index 0000000..08d1a38
--- /dev/null
+++ b/src/bin/git-sugpatch.rs
@@ -0,0 +1,25 @@
+use std::env;
+use std::process;
+
+use git_suggested_patch::{Client, SuggestionUrl};
+
+
+fn main() {
+ let args: Vec<_> = env::args().collect();
+
+ if args.len() < 2 {
+ process::exit(111);
+ }
+
+ let url: SuggestionUrl = args[1].parse().unwrap();
+
+ let client = Client::new(
+ env!("GITHUB_TOKEN"),
+ &url.owner,
+ &url.repo,
+ );
+
+ let suggestion = client.fetch(&url.comment_id).unwrap();
+
+ print!("{}", suggestion.diff());
+}