From c7c8add5e81e1d75de39289cf2c3a3ea2161b06b Mon Sep 17 00:00:00 2001 From: blackfur <64478051+TheBlackfurGuy@users.noreply.github.com> Date: Sat, 27 Aug 2022 14:54:47 +0200 Subject: [PATCH] Base Clap setup --- Cargo.toml | 1 + src/main.rs | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 31d5b26..50d5dc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +clap = {version = "*", features = ["derive"]} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index e7a11a9..07b5b1b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,22 @@ -fn main() { - println!("Hello, world!"); +use clap::{Parser, Subcommand, CommandFactory, ErrorKind}; + + +#[derive(Parser)] +struct Cli { + #[clap(subcommand)] + command: Option } + +#[derive(Subcommand)] +enum Commands { + Help +} + +fn main() { + let cli = Cli::parse(); + + match &cli.command { + Some(Commands::Help) => Cli::command().error(ErrorKind::DisplayHelp, ""), + None => Cli::command().error(ErrorKind::DisplayHelp, "") + }; +} \ No newline at end of file