aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/git-sugpatch.rs5
-rw-r--r--src/config.rs9
2 files changed, 13 insertions, 1 deletions
diff --git a/src/bin/git-sugpatch.rs b/src/bin/git-sugpatch.rs
index 9b2769a..c8fc0a8 100644
--- a/src/bin/git-sugpatch.rs
+++ b/src/bin/git-sugpatch.rs
@@ -20,6 +20,11 @@ fn main() {
};
if config.suggestions.is_empty() {
+ print!(
+ "{}",
+ config.usage("usage: git sugpatch [options] <suggestion>..."),
+ );
+
process::exit(exitcode::USAGE);
}
diff --git a/src/config.rs b/src/config.rs
index 57a4477..4402014 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -27,11 +27,12 @@ pub enum Error {
Git(#[from] git2::Error),
}
-#[derive(Debug)]
pub struct Config {
pub github_token: String,
pub o_r: Result<OwnerRepo, owner_repo::Error>,
pub suggestions: Vec<String>,
+
+ opts: Options,
}
impl Config {
@@ -53,9 +54,15 @@ impl Config {
github_token: Self::github_token(&opt_matches, &git_config)?,
o_r: o_r,
suggestions: opt_matches.free,
+
+ opts: opts,
})
}
+ pub fn usage(&self, brief: &str) -> String {
+ self.opts.usage(&brief)
+ }
+
fn github_token(
opt_matches: &getopts::Matches,
git_config: &git2::Config,