From b5f9bcca207ddb312adcf8e63ac7a430b6f0902f Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 2 Aug 2020 09:17:59 +0200 Subject: git-sugpatch: Print usage with no suggestion argumenet Add `Options` to `Config` to allow us to get a usage string from a `Config` instance, which is where we create `Options`. Needed to remove the `Debug` derive on `Config` in order to add the field as `Options` doesn't implement `Debug`. --- src/config.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/config.rs') 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, pub suggestions: Vec, + + 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, -- cgit v1.2.3