Base Clap setup
This commit is contained in:
parent
9f81214a5e
commit
c7c8add5e8
|
@ -6,3 +6,4 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
clap = {version = "*", features = ["derive"]}
|
23
src/main.rs
23
src/main.rs
|
@ -1,3 +1,22 @@
|
||||||
fn main() {
|
use clap::{Parser, Subcommand, CommandFactory, ErrorKind};
|
||||||
println!("Hello, world!");
|
|
||||||
|
|
||||||
|
#[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, "")
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue