aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/git-sugpatch.rs
blob: 2a9b3486c1eec174ad7a9a861a608b7adfdecd6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::env;
use std::process;

use github_suggestion::{Client, SuggestionUrl};
use github_suggestion_cli::config::Config;


fn main() {
    let args: Vec<_> = env::args().collect();

    let config = Config::get(&args).unwrap();

    if args.len() < 2 {
        process::exit(111);
    }

    let url: SuggestionUrl = args[1].parse().unwrap();

    let client = Client::new(
        &config.github_token,
        &config.owner,
        &config.repo,
    ).unwrap();

    let suggestion = client.fetch(&url.comment_id).unwrap();

    print!("{}", suggestion.diff().unwrap());
}