Base Clap setup

This commit is contained in:
blackfur 2022-08-27 14:54:47 +02:00
parent 9f81214a5e
commit c7c8add5e8
2 changed files with 22 additions and 2 deletions

View file

@ -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"]}

View file

@ -1,3 +1,22 @@
fn main() {
println!("Hello, world!");
use clap::{Parser, Subcommand, CommandFactory, ErrorKind};
#[derive(Parser)]
struct Cli {
#[clap(subcommand)]
command: Option<Commands>
}
#[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, "")
};
}