diff options
Diffstat (limited to 'src/cli.rs')
| -rw-r--r-- | src/cli.rs | 58 |
1 files changed, 36 insertions, 22 deletions
@@ -1,25 +1,39 @@ use structopt::StructOpt; +use structopt::clap::{Shell, App, AppSettings, SubCommand, Arg}; -#[derive(StructOpt, Debug)] -pub enum Command { - Run, - Config, -} - -#[derive(StructOpt, Debug)] -#[structopt( -name = env!("CARGO_PKG_NAME"), -about = env!("CARGO_PKG_DESCRIPTION"), -version = env!("CARGO_PKG_VERSION"), -author = env!("CARGO_PKG_AUTHORS"), -)] -pub struct Opt { - #[structopt(short, long)] - pub debug: bool, - - #[structopt(short, long, parse(from_occurrences))] - pub verbose: u8, - - #[structopt(subcommand)] // help - pub command: Command, +pub fn cli<'b, 'a>() -> App<'a, 'b> { + App::new(env!("CARGO_PKG_NAME")) + .about(env!("CARGO_PKG_DESCRIPTION")) + .version(env!("CARGO_PKG_VERSION")) + .author(env!("CARGO_PKG_AUTHORS")) + .settings(&[ + AppSettings::SubcommandRequiredElseHelp, + ]) + .subcommands(vec![ + SubCommand::with_name("run") + .about("Start the WorldServer"), + SubCommand::with_name("config") + .setting(AppSettings::SubcommandRequiredElseHelp) + .subcommands(vec![ + SubCommand::with_name("show"), + ]), + SubCommand::with_name("completions") + .setting(AppSettings::SubcommandRequiredElseHelp) + .about("Generate shell completions") + .subcommands(vec![ + SubCommand::with_name("powershell"), + SubCommand::with_name("bash"), + SubCommand::with_name("elvish"), + SubCommand::with_name("zsh"), + SubCommand::with_name("fish"), + ]), + ]) + .args(&[ + Arg::with_name("debug") + .short("d") + .long("debug"), + Arg::with_name("trace") + .short("t") + .long("trace"), + ]) } |