`#[clap(...)]`に指定できるパラメータについて。基本は[[structopt]]の仕様に準拠しているはず。
## ショートオプション
```rust
#[derive(Clap)]
struct Opts {
/// -d で指定可能に
#[clap(short)]
debug: bool
/// -v で指定可能に
#[clap(short = "v")]
hoge: bool
}
```
## ロングオプション
```rust
#[derive(Clap)]
struct Opts {
/// --debug で指定可能に
#[clap(long)]
debug: bool
/// --vava で指定可能に
#[clap(long = "vava")]
hoge: bool
}
```
## デフォルト値
```rust
#[derive(Clap)]
struct Opts {
/// 指定なしデフォルトだと .config が入る
#[clap(default_value = ".config")]
config: String
}
```
## 出現回数
主に`verbose`で使用する。
```rust
#[derive(Clap)]
struct Opts {
/// -vで1, -vvで2が入る. -v -v でも2が入る
#[clap(parse(from_occurrences), short)]
verbose: i32
}
```
## パス
```rust
#[derive(Clap)]
struct Opts {
/// OSによって最適な形式でinputに
#[clap(parse(from_os_str))]
input: PathBuf,
}
```
## サブコマンド
`enum`を挟んでコマンドを定義するのがポイント。
```rust
#[derive(Clap)]
struct Opts {
#[clap(subcommand)]
subcmd: SubCommand,
}
#[derive(Clap)]
enum SubCommand {
/// helpでこの説明とコマンド Usageが表示される
Uho(UhoOpts),
}
/// メインコマンドと同様にサブコマンドを定義する
#[derive(Clap)]
struct UhoOpts {}
```
## サブコマンドでも認識させる
```rust
#[derive(Clap)]
struct Opts {
/// サブコマンドの前、後どちらに -i を入れても認識する
#[clap(short, global = true)]
input: string,
}
```
## 複数回指定
型をそのように変える。
```rust
#[derive(Clap)]
struct Opts {
#[clap(short, long, parse(from_os_str))]
pub route_template: Vec<PathBuf>,
}
```