Actually use the clap dependency

This commit is contained in:
Sridhar Ratnakumar 2021-04-07 23:45:56 -04:00
parent 50be0563c3
commit 8ae61871a3
2 changed files with 16 additions and 6 deletions

View file

@ -14,4 +14,5 @@ jobs:
extra_nix_config: |
experimental-features = nix-command flakes
- run: nix develop -c rustc --version
- run: nix run . -- ping
- run: nix-build

View file

@ -1,4 +1,6 @@
use std::fmt::{Display, Formatter};
use clap::{App, SubCommand};
enum VertDir {
Up,
@ -107,6 +109,12 @@ impl Display for Game {
}
fn main () {
let matches = App::new("bouncy")
.version("1.0")
.subcommand(SubCommand::with_name("ping")).get_matches();
if let Some(_matches) = matches.subcommand_matches("ping") {
println!("pong")
} else {
let mut game = Game::new();
let sleep_duration = std::time::Duration::from_millis(33);
loop {
@ -114,4 +122,5 @@ fn main () {
game.step();
std::thread::sleep(sleep_duration);
}
}
}