dustin
/
aoc2021
Archived
1
0
Fork 0

Add subcommands to main command

The main command now supports subcommands for the various puzzles.  The
first subcommand is `sonar`, for working with the sonar data from the
Day 1 puzzles.
master
Dustin 2021-12-02 22:42:20 -06:00
parent 40f77c94ac
commit 733813e719
1 changed files with 21 additions and 3 deletions

View File

@ -5,8 +5,22 @@ use argh::FromArgs;
mod sonar;
#[derive(FromArgs)]
/// Elvish Submarine Sonar Tracker
/// Elvish Submarine Control
struct Arguments {
#[argh(subcommand)]
command: SubCommand,
}
#[derive(FromArgs)]
#[argh(subcommand)]
enum SubCommand {
Sonar(SonarTracker),
}
#[derive(FromArgs)]
/// sonar data reader
#[argh(subcommand, name = "sonar")]
struct SonarTracker {
/// path to input data file
#[argh(positional)]
input: String,
@ -18,7 +32,11 @@ struct Arguments {
fn main() -> io::Result<()> {
let args: Arguments = argh::from_env();
match args.command {
SubCommand::Sonar(args) => {
let count_incr = sonar::count_increases(&args.input, args.window)?;
println!("number of increases: {}", count_incr);
}
}
Ok(())
}