Skip to content

Commit

Permalink
Revert "Refactor subcommand handling (dandavison#1467)"
Browse files Browse the repository at this point in the history
Fixes dandavison#1475

This reverts commit 8d14a1e.
  • Loading branch information
dandavison committed Jul 19, 2023
1 parent 278cce0 commit fdaf4bf
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,42 +82,42 @@ 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);
};

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);
}

Expand Down

0 comments on commit fdaf4bf

Please sign in to comment.