From ee8a08bfa24d9a3d09273fdebe8d73ac38c545f9 Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Sat, 6 Sep 2025 09:30:39 +0200 Subject: Update guessing game Signed-off-by: Carlos Maiolino --- rust/echor/src/.main.rs.un~ | Bin 0 -> 82832 bytes rust/echor/src/main.rs | 34 ++++++++++++++++++++++++++++++++++ rust/echor/src/main.rs~ | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 rust/echor/src/.main.rs.un~ create mode 100644 rust/echor/src/main.rs create mode 100644 rust/echor/src/main.rs~ (limited to 'rust/echor/src') diff --git a/rust/echor/src/.main.rs.un~ b/rust/echor/src/.main.rs.un~ new file mode 100644 index 0000000..b993ba5 Binary files /dev/null and b/rust/echor/src/.main.rs.un~ differ diff --git a/rust/echor/src/main.rs b/rust/echor/src/main.rs new file mode 100644 index 0000000..323d4c7 --- /dev/null +++ b/rust/echor/src/main.rs @@ -0,0 +1,34 @@ +use clap::{App, Arg}; + +/* + * Lack of specified return value means the function will return an UNIT type + */ +fn main() { + let matches = App::new("echor") + .version("0.1.0") + .author("Ronaldo curintiano") + .about("echo rusty") + .arg( + Arg::with_name("text") + .value_name("TEXT") + .help("Input text") + .required(true) + .min_values(1), + ) + .arg( + Arg::with_name("omit_newline") + .value_name("OMIT NEWLINE") + .short("n") + .help("Do not print newline") + .takes_value(false), + ) + .get_matches(); + + let text = matches.values_of_lossy("text").unwrap().join(" "); + let omit_newline :bool = matches.is_present("omit_newline"); + + print!("{}{}", + text, + if omit_newline {""} else {"\n"}); + +} diff --git a/rust/echor/src/main.rs~ b/rust/echor/src/main.rs~ new file mode 100644 index 0000000..fc2d607 --- /dev/null +++ b/rust/echor/src/main.rs~ @@ -0,0 +1,34 @@ +use clap::{App, Arg}; + +/* + * Lack of specified return value means the function will return an UNIT type + */ +fn main() { + let matches = App::new("echor") + .version("0.1.0") + .author("Ronaldo curintiano") + .about("echo rusty") + .arg( + Arg::with_name("text") + .value_name("TEXT") + .help("Input text") + .required(true) + .min_values(1), + ) + .arg( + Arg::with_name("omit_newline") + .value_name("OMIT NEWLINE") + .short("n") + .help("Do not print newline") + .takes_value(false), + ) + .get_matches(); + + let text = matches.values_of_lossy("text").unwrap().join(" "); + let omit_newline :bool = matches.is_present("omit_newline"); + + print("{}{}", + text, + if omit_newline {""} else {"\n"}); + +} -- cgit v1.2.3