diff options
author | Teddy Wing | 2020-08-02 00:47:53 +0200 |
---|---|---|
committer | Teddy Wing | 2020-08-02 00:47:53 +0200 |
commit | 13710b49cc40c0e78eec9a94ce9b0ea8a09c3860 (patch) | |
tree | 0ded95e864a307ba733a9134f28df40273665873 /src/bin/git-sugpatch.rs | |
parent | dff81f7b84c279d7e00fe7a885743605a2ac5b7e (diff) | |
download | git-suggestion-13710b49cc40c0e78eec9a94ce9b0ea8a09c3860.tar.bz2 |
git-sugpatch: Print error and exit on `Config::get` error
Add `exitcode` to exit with an appropriate code.
Add the `gseprintln` macro to wrap `eprintln!()`, prefixing the output
with "error: ".
Diffstat (limited to 'src/bin/git-sugpatch.rs')
-rw-r--r-- | src/bin/git-sugpatch.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/bin/git-sugpatch.rs b/src/bin/git-sugpatch.rs index 04b687d..0159307 100644 --- a/src/bin/git-sugpatch.rs +++ b/src/bin/git-sugpatch.rs @@ -1,7 +1,10 @@ use std::env; use std::process; +use exitcode; + use github_suggestion::{Client, Suggestion, SuggestionUrl}; +use github_suggestion_cli::gseprintln; use github_suggestion_cli::config::Config; use github_suggestion_cli::error::Error; use github_suggestion_cli::is_suggestion_id; @@ -10,7 +13,14 @@ use github_suggestion_cli::is_suggestion_id; fn main() { let args: Vec<_> = env::args().collect(); - let config = Config::get(&args).unwrap(); + let config = match Config::get(&args) { + Ok(c) => c, + Err(e) => { + gseprintln!(e); + + process::exit(exitcode::DATAERR); + }, + }; if config.suggestions.is_empty() { process::exit(111); |