Actually use the clap dependency
This commit is contained in:
parent
50be0563c3
commit
8ae61871a3
2 changed files with 16 additions and 6 deletions
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
|
@ -14,4 +14,5 @@ jobs:
|
||||||
extra_nix_config: |
|
extra_nix_config: |
|
||||||
experimental-features = nix-command flakes
|
experimental-features = nix-command flakes
|
||||||
- run: nix develop -c rustc --version
|
- run: nix develop -c rustc --version
|
||||||
|
- run: nix run . -- ping
|
||||||
- run: nix-build
|
- run: nix-build
|
||||||
|
|
21
src/main.rs
21
src/main.rs
|
@ -1,4 +1,6 @@
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
|
use clap::{App, SubCommand};
|
||||||
|
|
||||||
|
|
||||||
enum VertDir {
|
enum VertDir {
|
||||||
Up,
|
Up,
|
||||||
|
@ -107,11 +109,18 @@ impl Display for Game {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main () {
|
fn main () {
|
||||||
let mut game = Game::new();
|
let matches = App::new("bouncy")
|
||||||
let sleep_duration = std::time::Duration::from_millis(33);
|
.version("1.0")
|
||||||
loop {
|
.subcommand(SubCommand::with_name("ping")).get_matches();
|
||||||
println!("{}", game);
|
if let Some(_matches) = matches.subcommand_matches("ping") {
|
||||||
game.step();
|
println!("pong")
|
||||||
std::thread::sleep(sleep_duration);
|
} else {
|
||||||
|
let mut game = Game::new();
|
||||||
|
let sleep_duration = std::time::Duration::from_millis(33);
|
||||||
|
loop {
|
||||||
|
println!("{}", game);
|
||||||
|
game.step();
|
||||||
|
std::thread::sleep(sleep_duration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue