Add user feedback loop and header comments
This commit is contained in:
parent
e59ea4851f
commit
7e7e2d10e4
1 changed files with 24 additions and 2 deletions
26
src/main.rs
26
src/main.rs
|
@ -1,3 +1,7 @@
|
||||||
|
// James Musselman
|
||||||
|
// Released under AGPL-v3.0-or-later
|
||||||
|
// This program generates a version name using a random alliterative animal and adjective from their respective files.
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{self, BufRead};
|
use std::io::{self, BufRead};
|
||||||
use inflector::Inflector;
|
use inflector::Inflector;
|
||||||
|
@ -30,6 +34,7 @@ fn main() -> io::Result<()> {
|
||||||
|
|
||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// Generate random lines
|
// Generate random lines
|
||||||
let animal = animal_lines.choose(&mut rng).unwrap();
|
let animal = animal_lines.choose(&mut rng).unwrap();
|
||||||
|
@ -38,8 +43,25 @@ fn main() -> io::Result<()> {
|
||||||
// Check if the first character of adjective and animal match
|
// Check if the first character of adjective and animal match
|
||||||
if animal.chars().next() == adjective.chars().next() {
|
if animal.chars().next() == adjective.chars().next() {
|
||||||
// Print the matched version name
|
// Print the matched version name
|
||||||
println!("Your new Version Name:\n{} {}", adjective, animal);
|
println!("\n{} {}\n", adjective, animal);
|
||||||
break;
|
|
||||||
|
println!("Are you satisfied? (y/n)");
|
||||||
|
|
||||||
|
let mut input = String::new();
|
||||||
|
io::stdin().read_line(&mut input).expect("Failed to read line");
|
||||||
|
|
||||||
|
// Trim leading/trailing whitespaces
|
||||||
|
let input = input.trim();
|
||||||
|
|
||||||
|
if input.eq_ignore_ascii_case("y") {
|
||||||
|
break;
|
||||||
|
} else if input.eq_ignore_ascii_case("n") {
|
||||||
|
println!("Generating new output...")
|
||||||
|
|
||||||
|
} else {
|
||||||
|
println!("Invalid input. Please enter 'y' or 'n'.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue