Skip to content

Commit

Permalink
Added 2 new flags!111
Browse files Browse the repository at this point in the history
  • Loading branch information
metamethods committed Jan 6, 2024
1 parent b29be5d commit d165859
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "unix-no"
version = "0.2.5"
version = "0.2.6"
edition = "2021"
license = "GPL-3.0"
description = "Output a string repeatedly until killed."
Expand Down
31 changes: 26 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,42 @@ struct Args {

/// Wait x milliseconds between each line.
#[arg(short, long)]
interval: Option<u64>
interval: Option<u64>,

/// Yes
#[arg(short, long)]
yes: bool,

/// Count
#[arg(short, long)]
count: Option<u32>
}

fn main() {
let string = Args::parse().strings
let args = Args::parse();
let string = args.strings
.unwrap_or(vec!["n".to_string()])
.join(" ");

let interval = Args::parse().interval;
let mut current_count: u32 = 0;

loop {
println!("{string}");
current_count += 1;

if let Some(interval) = interval {
if args.yes {
println!("y");
} else {
println!("{string}");
}

if let Some(interval) = args.interval {
thread::sleep(time::Duration::from_millis(interval));
}

if let Some(max_count) = args.count {
if current_count >= max_count {
break;
}
}
}
}

0 comments on commit d165859

Please sign in to comment.