Skip to content

Commit

Permalink
Build subcommands structure
Browse files Browse the repository at this point in the history
  • Loading branch information
SyedAhkam committed Apr 12, 2023
1 parent d9bca8a commit 72b5387
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/commands/create.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use clap::Parser;

#[derive(Parser, Debug)]
pub struct Create {
#[clap(short, long)]
name: String,
}

pub fn handle(args: Create) {
println!("Create command: {}", args.name)
}
1 change: 1 addition & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod create;
24 changes: 18 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
use clap::Parser;
use clap::{Parser, Subcommand};

mod commands;

/// Create, build, and release Android apps faster without Android Studio
#[derive(Parser, Debug)]
#[clap(name = "android")]
#[clap(name = "Android CLI")]
#[clap(author, version, about)]
#[clap(author = "Syed Ahkam <[email protected]>")]
#[clap(arg_required_else_help = true)]
struct Cli {}
struct Cli {
#[clap(subcommand)]
command: SubCommand,
}

#[derive(Subcommand, Debug)]
enum SubCommand {
Create(commands::create::Create),
}

fn main() {
let _args = Cli::parse();
let args = Cli::parse();

println!("Hello, world!");
match args.command {
SubCommand::Create(args) => commands::create::handle(args),
}
}

0 comments on commit 72b5387

Please sign in to comment.