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: | 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

View file

@ -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,6 +109,12 @@ impl Display for Game {
} }
fn main () { 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 mut game = Game::new();
let sleep_duration = std::time::Duration::from_millis(33); let sleep_duration = std::time::Duration::from_millis(33);
loop { loop {
@ -115,3 +123,4 @@ fn main () {
std::thread::sleep(sleep_duration); std::thread::sleep(sleep_duration);
} }
} }
}