diff options
| author | lukeflo | 2025-10-15 08:50:54 +0200 |
|---|---|---|
| committer | lukeflo | 2025-10-15 08:50:54 +0200 |
| commit | 7d59b6c816fa81c13cdf8348a2e7db0076015cd1 (patch) | |
| tree | 06e863cc52411cf041ca0d118c1334c7d3e3bac2 /src/main.rs | |
| parent | 34170cfa62df5443a0d8675106c553efec035687 (diff) | |
| parent | db882623358d9141927bd31f6825472f2cdca4b6 (diff) | |
| download | bibiman-7d59b6c816fa81c13cdf8348a2e7db0076015cd1.tar.gz bibiman-7d59b6c816fa81c13cdf8348a2e7db0076015cd1.zip | |
Merge pull request 'implement basic citekey formatting' (#58) from format-citekeys-#55 into main
Reviewed-on: https://codeberg.org/lukeflo/bibiman/pulls/58
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(()) } |
