Skip to content

Commit

Permalink
refactor(crate): Eleminate common prefix in enum for clippy's sake
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Oct 25, 2024
1 parent 3bf12a1 commit d9d8269
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/bin/decasify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ use std::io::BufRead;
#[derive(Snafu)]
enum Error {
#[snafu(display("Failed to identify input"))]
InvalidInput {},
Input {},

#[snafu(display("Failed to resolve a known locale"))]
InvalidLocale {},
Locale {},

#[snafu(display("Failed to resolve a known case"))]
InvalidCase {},
Case {},

#[snafu(display("Failed to resolve a known style guide"))]
InvalidStyleGuide {},
StyleGuide {},
}

// Clap CLI errors are reported using the Debug trait, but Snafu sets up the Display trait.
Expand All @@ -40,22 +40,20 @@ fn main() -> Result<()> {
let version = option_env!("VERGEN_GIT_DESCRIBE").unwrap_or_else(|| env!("CARGO_PKG_VERSION"));
let app = Cli::command().version(version);
let matches = app.get_matches();
let locale = matches
.get_one::<Locale>("locale")
.context(InvalidLocaleSnafu)?;
let locale = matches.get_one::<Locale>("locale").context(LocaleSnafu)?;
let case = matches
.get_one::<Case>("case")
.context(InvalidCaseSnafu)?
.context(CaseSnafu)?
.to_owned();
let style = matches
.get_one::<StyleGuide>("style")
.context(InvalidStyleGuideSnafu)?
.context(StyleGuideSnafu)?
.to_owned();
match matches.contains_id("input") {
true => {
let input: Vec<String> = matches
.get_many::<String>("input")
.context(InvalidInputSnafu)?
.context(InputSnafu)?
.cloned()
.collect();
let input: Vec<String> = vec![input.join(" ")];
Expand Down

0 comments on commit d9d8269

Please sign in to comment.