diff --git a/Cargo.toml b/Cargo.toml index de25a3e..294df7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +clap = { version = "4.5", features = ["cargo", "derive"] } [dev-dependencies] cc-cli = "0.1.5" diff --git a/src/main.rs b/src/main.rs index e7a11a9..f8beee0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,36 @@ -fn main() { - println!("Hello, world!"); +use clap::Parser; + +#[derive(Parser, Debug)] +#[clap(version = clap::crate_version!(), author = clap::crate_authors!(), about = clap::crate_description!())] +struct Commands { + #[clap(subcommand)] + command: Command, +} +#[derive(Parser, Debug)] +enum Command { + Init, + #[clap(subcommand)] + Server(Server), +} +#[derive(Parser, Debug)] +enum Server { + Init, + Start, +} +fn main() { + let commands = Commands::parse(); + + match commands.command { + Command::Init => { + println!("Init command"); + } + Command::Server(server) => match server { + Server::Init => { + println!("Server Init command"); + } + Server::Start => { + println!("Server Start command"); + } + }, + } }