use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None,
propagate_version = true, arg_required_else_help = true,
after_help = "\
EXAMPLES:
search google <word> // search word
search google - // search word from stdin
search g <word> // alias
search config -p // print config file path
search list // list providers
"
)]
pub struct Cli {
#[clap(subcommand)]
pub subcommand: SubCommand,
}
#[derive(Subcommand, Debug)]
pub enum SubCommand {
Config(CommandConfig),
List(CommandList),
Open(CommandOpen),
Completion(CommandCompletion),
#[clap(about = "Show config.yaml schema")]
Jsonschema,
#[clap(external_subcommand)]
External(Vec<String>),
}
#[derive(Parser, Debug)]
#[clap(arg_required_else_help = true, about = "Configuration")]
pub struct CommandConfig {
#[clap(long, short, help = "Print config file path")]
pub path: bool,
}
#[derive(Parser, Debug)]
#[clap(about = "List search providers")]
pub struct CommandList {
#[clap(long, short)]
pub verbose: bool,
}
#[derive(Parser, Debug)]
#[clap(arg_required_else_help = true, about = "Search words")]
pub struct CommandOpen {
#[clap(long, short)]
pub provider: Option<String>,
pub word: String,
}
#[derive(Parser, Debug)]
#[clap(
arg_required_else_help = true,
about = "Generate completion scripts",
after_help = "\
EXAMPLES:
search completion bash
search completion powershell
search completion fish
search completion zsh
"
)]
pub struct CommandCompletion {
pub shell: clap_complete::Shell,
}