From e53ba4f2a16ce1a0b409b3e68bd20611fc9df3ee Mon Sep 17 00:00:00 2001 From: materus Date: Wed, 20 Mar 2024 19:17:26 +0100 Subject: [PATCH] Add more failure messages --- src/main.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 0f869ca..f4ce3d8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,7 +67,6 @@ async fn setup_key(key: String) -> Result> { #[tokio::main] async fn main() -> Result> { let args = Cli::parse(); - let all_args = args.currency_from.is_some() && args.currency_to.is_some() && args.value.is_some(); let wrong_args = @@ -77,8 +76,17 @@ async fn main() -> Result> { println!("Do not provide codes and value with --interactive"); return Ok(ExitCode::FAILURE); } + if args.interactive && (args.list || args.list_rates.is_some()) { + println!("Can't use --list or --list-rates with --interactive"); + return Ok(ExitCode::FAILURE); + } + if args.currency_from.is_some() && (args.list || args.list_rates.is_some()) { + println!("Can't use --list or --list-rates while providing exchange data"); + return Ok(ExitCode::FAILURE); + } if args.recreate_cache || !config::get_cache_path().exists() { create_cache()?; + println!("New cache was created"); } match args.api_key { None => {} @@ -97,9 +105,14 @@ async fn main() -> Result> { .len() > 0) { + println!("API Key is not set up!"); return Ok(ExitCode::FAILURE); } + if args.list && args.list_rates.is_some(){ + println!("Can't use --list with --list-rates"); + return Ok(ExitCode::FAILURE); + } if args.list { let currencies = cache::list_currencies()?; for currency in currencies {