Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proper error handling for conflicting flags #99

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{

use strsim::normalized_damerau_levenshtein;

use crate::{arg_flag, flag, oof, Error};
use crate::{arg_flag, error::FinalError, flag, oof, Error};

#[derive(PartialEq, Eq, Debug)]
pub enum Command {
Expand Down Expand Up @@ -47,7 +47,13 @@ pub fn parse_args() -> crate::Result<ParsedArgs> {
}

if parsed_args.flags.is_present("yes") && parsed_args.flags.is_present("no") {
todo!("conflicting flags, better error message.");
return Err(Error::Custom {
reason: FinalError::with_title("Conflicted flags detected.")
.detail("You can't use both --yes and --no at the same time.")
.hint("Use --yes if you want to positively skip overwrite questions")
.hint("Use --no if you want to negatively skip overwrite questions")
.hint("Don't use either if you want to be asked each time"),
});
}

Ok(parsed_args)
Expand Down