diff options
| author | Teddy Wing | 2020-08-01 19:55:55 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2020-08-01 19:55:55 +0200 | 
| commit | 58b81567354cf6c0bd3623e86deb7b6609b1f3be (patch) | |
| tree | 72727284795a09add11df05afe11827cb641e64a /src/bin | |
| parent | 0addf6814485c98c5a9569633f6c4ca4e71038ed (diff) | |
| download | git-suggestion-58b81567354cf6c0bd3623e86deb7b6609b1f3be.tar.bz2 | |
Get config
We need the following values in order to build a `Client`:
* GitHub token
* Repo owner
* Repo name
Get the token from a command-line argument, or else the Git config, or
else an environment variable.
Get the repo identifiers from the repo's remote URL. Use the remote
specified as a command-line argument, otherwise get it from the Git
config, or else default to "origin".
TODO: Only try to get the owner-name pair from the remote if a comment
ID was given, not if a URL argument was passed.
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/git-sugpatch.rs | 9 | 
1 files changed, 6 insertions, 3 deletions
| diff --git a/src/bin/git-sugpatch.rs b/src/bin/git-sugpatch.rs index 0ad8874..2a9b348 100644 --- a/src/bin/git-sugpatch.rs +++ b/src/bin/git-sugpatch.rs @@ -2,11 +2,14 @@ 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);      } @@ -14,9 +17,9 @@ fn main() {      let url: SuggestionUrl = args[1].parse().unwrap();      let client = Client::new( -        env!("GITHUB_TOKEN"), -        &url.owner, -        &url.repo, +        &config.github_token, +        &config.owner, +        &config.repo,      ).unwrap();      let suggestion = client.fetch(&url.comment_id).unwrap(); | 
