summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2023-07-18 21:58:42 -0700
committerDan Davison <dandavison7@gmail.com>2023-07-18 22:00:30 -0700
commitfdaf4bfe1d8b59b397b069429b48c655bfc358a8 (patch)
tree95789581c7831f0a95907edae0259ed5ed74232a
parent278cce0e9107a892ac8dee0459b70f4b2c34b7ea (diff)
Revert "Refactor subcommand handling (#1467)"
Fixes #1475 This reverts commit 8d14a1eba3ca93d6f6ebf3be541b37c6677139a6.
-rw-r--r--src/main.rs42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/main.rs b/src/main.rs
index ba471102..a1f12622 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -82,24 +82,31 @@ fn run_app() -> std::io::Result<i32> {
assets,
);
- if let Err(error) = if opt.list_languages {
- list_languages()
+ let subcommand_result = if opt.list_languages {
+ Some(list_languages())
} else if opt.list_syntax_themes {
- subcommands::list_syntax_themes::list_syntax_themes()
+ Some(subcommands::list_syntax_themes::list_syntax_themes())
} else if opt.show_syntax_themes {
- subcommands::show_syntax_themes::show_syntax_themes()
+ Some(subcommands::show_syntax_themes::show_syntax_themes())
} else if opt.show_themes {
- subcommands::show_themes::show_themes(opt.dark, opt.light, opt.computed.is_light_mode)
+ Some(subcommands::show_themes::show_themes(
+ opt.dark,
+ opt.light,
+ opt.computed.is_light_mode,
+ ))
} else if opt.show_colors {
- subcommands::show_colors::show_colors()
+ Some(subcommands::show_colors::show_colors())
} else if opt.parse_ansi {
- subcommands::parse_ansi::parse_ansi()
+ Some(subcommands::parse_ansi::parse_ansi())
} else {
- Ok(())
- } {
- match error.kind() {
- ErrorKind::BrokenPipe => {}
- _ => fatal(format!("{error}")),
+ None
+ };
+ if let Some(result) = subcommand_result {
+ if let Err(error) = result {
+ match error.kind() {
+ ErrorKind::BrokenPipe => {}
+ _ => fatal(format!("{error}")),
+ }
}
return Ok(0);
};
@@ -107,17 +114,10 @@ fn run_app() -> std::io::Result<i32> {
let _show_config = opt.show_config;
let config = config::Config::from(opt);
- if let Err(error) = if _show_config {
+ if _show_config {
let stdout = io::stdout();
let mut stdout = stdout.lock();
- subcommands::show_config::show_config(&config, &mut stdout)
- } else {
- Ok(())
- } {
- match error.kind() {
- ErrorKind::BrokenPipe => {}
- _ => fatal(format!("{error}")),
- }
+ subcommands::show_config::show_config(&config, &mut stdout)?;
return Ok(0);
}