From ec385d1c1e9506fa0e7a7d04dc57392392d5ab3c Mon Sep 17 00:00:00 2001 From: ducdetronquito Date: Sat, 23 Dec 2023 10:46:04 +0100 Subject: [PATCH] feat: Implement the shell of the CLI API --- src/main.rs | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e7a11a9..e507af7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,35 @@ +use clap::{Parser, Subcommand}; + +#[derive(Parser, Debug)] +#[command(version)] +#[command(about = "🎂 CLI tool to remember birthdays of people you know")] +struct Cli { + #[command(subcommand)] + command: Command, +} + +#[derive(Subcommand, Debug)] +enum Command { + #[command(about = "Add a person's birthday")] + Add { name: String, date: String }, + #[command(about = "Show all birthdays")] + All {}, + #[command(about = "Show the next birthday")] + Next {}, + + #[command(about = "Search for birthdays")] + #[command(arg_required_else_help(true))] + Search { + #[arg(short, long, help = "match for names containing ")] + name: Option, + #[arg(short, long, help = "match for a specific ")] + date: Option, + }, + #[command(about = "Show today's birthdays")] + Today {}, +} + fn main() { - println!("Hello, world!"); + let args = Cli::parse(); + println!("You ran cli with: {:?}", args); }