diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/src/main.rs b/src/main.rs index c956d7c..e735eb0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,6 @@ use app::App; use cliargs::CLIArgs; use color_eyre::eyre::Result; -use config::BibiConfig; use errorsetup::init_error_hooks; pub mod app; @@ -31,41 +30,16 @@ pub mod tui; #[tokio::main] async fn main() -> Result<()> { // Parse CLI arguments - let mut parsed_args = CLIArgs::parse_args()?; + let (mut parsed_args, mut cfg, run_tui) = CLIArgs::parse_args()?; - // Print help if -h/--help flag is passed and exit - if parsed_args.helparg { - println!("{}", cliargs::help_func()); - std::process::exit(0); - } + if run_tui { + init_error_hooks()?; - // Print version if -v/--version flag is passed and exit - if parsed_args.versionarg { - println!("{}", cliargs::version_func()); - std::process::exit(0); - } + // Create an application. + let mut app = App::new(&mut parsed_args, &mut cfg)?; - if parsed_args - .cfg_path - .as_ref() - .is_some_and(|f| !f.try_exists().unwrap() || !f.is_file()) - { - BibiConfig::create_default_config(&parsed_args); + app.run(&cfg).await?; } - let mut cfg = if parsed_args.cfg_path.is_some() { - BibiConfig::parse_config(&parsed_args)? - } else { - BibiConfig::new(&parsed_args) - }; - - cfg.cli_overwrite(&parsed_args); - - init_error_hooks()?; - - // Create an application. - let mut app = App::new(&mut parsed_args, &mut cfg)?; - - app.run(&cfg).await?; Ok(()) } |
