Skip to content

Commit

Permalink
fix: fixes origin not being parsed for subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
someguynamedmatt committed Apr 29, 2020
1 parent 121f1b7 commit 4655064
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/commands/releases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub fn make_app<'a, 'b: 'a>(app: App<'a, 'b>) -> App<'a, 'b> {
.about("Create a new release.")
.version_arg(1)
.projects_arg()
.org_arg()
// this is deprecated and no longer does anything
.arg(Arg::with_name("ref")
.long("ref")
Expand Down
29 changes: 20 additions & 9 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,27 @@ impl Config {

/// Given a match object from clap, this returns the org from it.
pub fn get_org(&self, matches: &ArgMatches<'_>) -> Result<String, Error> {
Ok(matches
.value_of("org")
.map(str::to_owned)
.or_else(|| env::var("SENTRY_ORG").ok())
.or_else(|| {
self.ini
.get_from(Some("defaults"), "org")
match matches.subcommand_name() {
None => {
Ok(matches
.value_of("org")
.map(str::to_owned)
})
.ok_or_else(|| err_msg("An organization slug is required (provide with --org)"))?)
.or_else(|| env::var("SENTRY_ORG").ok())
.or_else(|| {
self.ini
.get_from(Some("defaults"), "org")
.map(str::to_owned)
})
.ok_or_else(|| err_msg("An organization slug is required (provide with --org)"))?)
}
Some(subcommand) => {
if let Some(sub_matches) = matches.subcommand_matches(subcommand) {
self.get_org(sub_matches)
} else {
Err(err_msg("An organization slug is required (provide with --org)"))
}
}
}
}

/// Given a match object from clap, this returns a tuple in the
Expand Down

0 comments on commit 4655064

Please sign in to comment.