Skip to content

Commit 446de5f

Browse files
committed
refactor: remove get_suggestion
1 parent 895686d commit 446de5f

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

cli/src/main.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,16 @@ fn main() -> Result<(), Error> {
1111
let cli = Cli::parse();
1212
if let Err(e) = cli.run() {
1313
log::error(&e.to_string());
14-
if let Some(suggestion) = get_suggestion(&e) {
15-
log::warning(suggestion);
14+
match e {
15+
Error::CliError(CliError::RepositoryExists) => {
16+
log::warning("Try removing the existing directory or use a different path.")
17+
}
18+
Error::CliError(CliError::InvalidUsage) => {
19+
log::warning("Run 'dm help' for usage information.")
20+
}
21+
Error::CliError(CliError::CancelledByUser) => log::warning("No changes were made."),
22+
_ => {}
1623
}
1724
}
1825
Ok(())
1926
}
20-
21-
fn get_suggestion(e: &Error) -> Option<&'static str> {
22-
match e {
23-
Error::CliError(CliError::RepositoryExists) => {
24-
Some("Try removing the existing directory or use a different path.")
25-
}
26-
Error::CliError(CliError::InvalidUsage) => Some("Run 'dm help' for usage information."),
27-
Error::CliError(CliError::CancelledByUser) => Some("No changes were made."),
28-
_ => None,
29-
}
30-
}

0 commit comments

Comments
 (0)