Skip to content

Commit

Permalink
Extract strikes count to output
Browse files Browse the repository at this point in the history
  • Loading branch information
tbsklg committed Aug 28, 2024
1 parent 7ea1cef commit f98b6e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cli-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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 => {
Expand Down
4 changes: 4 additions & 0 deletions cli-client/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ pub fn print_as_table(tarnished: Vec<Tarnished>) {
println!("{0: <10} | {1: <10} |", tarnished.name, tarnished.strikes);
}
}

pub fn print_strikes(name: &str, strikes: i8) {
println!("{} has now {} strikes!", name, strikes);
}

0 comments on commit f98b6e0

Please sign in to comment.