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: |
|
||||
experimental-features = nix-command flakes
|
||||
- run: nix develop -c rustc --version
|
||||
- run: nix run . -- ping
|
||||
- run: nix-build
|
||||
|
|
21
src/main.rs
21
src/main.rs
|
@ -1,4 +1,6 @@
|
|||
use std::fmt::{Display, Formatter};
|
||||
use clap::{App, SubCommand};
|
||||
|
||||
|
||||
enum VertDir {
|
||||
Up,
|
||||
|
@ -107,11 +109,18 @@ impl Display for Game {
|
|||
}
|
||||
|
||||
fn main () {
|
||||
let mut game = Game::new();
|
||||
let sleep_duration = std::time::Duration::from_millis(33);
|
||||
loop {
|
||||
println!("{}", game);
|
||||
game.step();
|
||||
std::thread::sleep(sleep_duration);
|
||||
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 {
|
||||
println!("{}", game);
|
||||
game.step();
|
||||
std::thread::sleep(sleep_duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue