stackline-cli: Exit command and condition

main
Shad Amethyst 2 years ago
parent 99bc677a92
commit d4a6522d07
Signed by: amethyst
GPG Key ID: D970C8DD1D6DEE36

@ -34,12 +34,16 @@ fn main() {
loop { loop {
let mut line = String::new(); let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap(); if let Ok(0) = std::io::stdin().read_line(&mut line) {
break; // EOF
}
line = line.trim().to_string(); line = line.trim().to_string();
let mut tokens = line.split(' '); let mut tokens = line.split(' ');
match tokens.next() { match tokens.next() {
None => continue, None => continue,
Some("exit") => break,
Some("run") => { Some("run") => {
if let Some(Ok(steps)) = tokens.next().map(|s| s.parse::<usize>()) { if let Some(Ok(steps)) = tokens.next().map(|s| s.parse::<usize>()) {
run(&mut world, steps).unwrap(); run(&mut world, steps).unwrap();
@ -200,6 +204,7 @@ fn main() {
} }
Some("help") => { Some("help") => {
println!("- `exit`: exits");
println!("- `print`: prints the current world"); println!("- `print`: prints the current world");
println!("- `get <x> <y>`: prints the JSON-serialized data of the tile at (x, y)"); println!("- `get <x> <y>`: prints the JSON-serialized data of the tile at (x, y)");
println!("- `set <x> <y> <tilename>`: sets the tile at (x, y) to a default tilename"); println!("- `set <x> <y> <tilename>`: sets the tile at (x, y) to a default tilename");

Loading…
Cancel
Save