aboutsummaryrefslogtreecommitdiff
path: root/src/cli.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-03-29 22:51:27 +0000
committerFuwn <[email protected]>2021-03-29 22:51:27 +0000
commitfa29e724932d2b1ab36ebcd8a3735e2efcf790fc (patch)
treed6d4ae58dc3360590294118bab9289881c76124b /src/cli.rs
parentfeature: Allow `Makefile` to accept arguments (diff)
downloadwhirl-fa29e724932d2b1ab36ebcd8a3735e2efcf790fc.tar.xz
whirl-fa29e724932d2b1ab36ebcd8a3735e2efcf790fc.zip
format: Refactor CLI, use pure `clap` instead of StructOpt
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs58
1 files changed, 36 insertions, 22 deletions
diff --git a/src/cli.rs b/src/cli.rs
index f59139d..08ce080 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -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"),
+ ])
}