From 323a4fa3c75794885199b580f266e436f6c646a2 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Fri, 18 Jul 2025 18:58:11 +0200 Subject: Add integration tests --- src/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 9245dcc..b84939c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ mod utils; use command::{Command, available_commands, help::Help}; use configuration::Configuration; use std::env::args; -use std::io::Result; +use std::io::{Error, Result}; use std::iter::once; fn main() -> Result<()> { @@ -35,6 +35,7 @@ fn run() -> Result<()> { let configuration = Configuration::new()?; let commands = available_commands(); let arguments: Vec = args().collect(); + let message; if let Some(command_name) = arguments.get(1) { if let Some(main_command) = commands.into_iter().find(|c| c.command() == command_name) { @@ -53,7 +54,11 @@ fn run() -> Result<()> { return Ok(()); } + message = format!("Command {command_name} does not exist."); + } else { + message = "You must provide at least one command.".to_string(); } - Help::new().execute(None, &configuration, "help") + Help::new().execute(None, &configuration, "help")?; + Err(Error::other(message)) } -- cgit