1// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu> 2// 3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or 4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 6// option. This file may not be copied, modified, or distributed 7// except according to those terms. 8 9use clap::Parser; 10 11#[derive(Parser, Debug)] 12#[command(name = "make-cookie")] 13struct MakeCookie { 14 #[arg(short)] 15 s: String, 16 17 #[command(subcommand, skip)] 18 cmd: Command, 19} 20 21#[derive(Parser, Debug)] 22enum Command { 23 #[command(name = "pound")] 24 /// Pound acorns into flour for cookie dough. 25 Pound { acorns: u32 }, 26 27 Sparkle { 28 #[arg(short)] 29 color: String, 30 }, 31} 32 33impl Default for Command { 34 fn default() -> Self { 35 Command::Pound { acorns: 0 } 36 } 37} 38 39fn main() { 40 let opt = MakeCookie::parse(); 41 println!("{:?}", opt); 42} 43