From f98b6e05871bedafc2653b981ddc0d6ca3cee8a2 Mon Sep 17 00:00:00 2001 From: Tobias Klug Date: Wed, 28 Aug 2024 15:34:38 +0200 Subject: [PATCH] Extract strikes count to output --- cli-client/src/main.rs | 4 ++-- cli-client/src/output.rs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cli-client/src/main.rs b/cli-client/src/main.rs index ea6772f..fa3b0bd 100644 --- a/cli-client/src/main.rs +++ b/cli-client/src/main.rs @@ -4,7 +4,7 @@ use strikes::clients::client::StrikeClient; use strikes::clients::local_client::LocalClient; use strikes::clients::remote_client::RemoteClient; use strikes::configuration::{get_configuration, Settings}; -use strikes::output::print_as_table; +use strikes::output::{print_as_table, print_strikes}; #[tokio::main] async fn main() { @@ -14,7 +14,7 @@ async fn main() { match &args.clone().command.unwrap() { Command::Strike { name } => match client.add_strike(name).await { - Ok(strikes) => println!("{} has now {} strikes!", name, strikes), + Ok(strikes) => print_strikes(name, strikes), Err(err) => eprintln!("Failed to add strike: {}", err), }, Command::Ls => { diff --git a/cli-client/src/output.rs b/cli-client/src/output.rs index 4842a98..ef18264 100644 --- a/cli-client/src/output.rs +++ b/cli-client/src/output.rs @@ -6,3 +6,7 @@ pub fn print_as_table(tarnished: Vec) { println!("{0: <10} | {1: <10} |", tarnished.name, tarnished.strikes); } } + +pub fn print_strikes(name: &str, strikes: i8) { + println!("{} has now {} strikes!", name, strikes); +}