From 6cd0e7935e4a487f3f328466b93ea9e5b03ce733 Mon Sep 17 00:00:00 2001 From: Mr-Ker <58399419+Mr-Ker@users.noreply.github.com> Date: Fri, 29 Nov 2024 22:21:20 +0000 Subject: [PATCH] Add clap argument parser The program will accept 2 optional arguments, one to the select the input folder, the other one to select for folder for the inputs. --- Cargo.toml | 1 + src/main.rs | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6cdd29c..4eb82fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,3 +4,4 @@ version = "0.1.0" edition = "2021" [dependencies] +clap = { version = "4.5.21", features = ["derive"] } diff --git a/src/main.rs b/src/main.rs index e7a11a9..680a0a0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,16 @@ -fn main() { - println!("Hello, world!"); +use clap::Parser; + +#[derive(Parser, Debug)] +#[command(version, about, long_about = None)] +struct Args { + #[arg(short, long, default_value_t = String::from("input_examples"))] + input_folder: String, + #[arg(short, long, default_value_t = 1)] + day: u8, } + +fn main() { + let args = Args::parse(); + + println!("Running day {} with input folder <{}>!", args.day, args.input_folder); +} \ No newline at end of file