CLI help: Group related options in categories

This commit is contained in:
RunasSudo 2021-05-29 23:25:05 +10:00
parent 77cf60c21f
commit 8a92c17cb3
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
3 changed files with 15 additions and 25 deletions

24
Cargo.lock generated
View File

@ -21,8 +21,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "clap"
version = "3.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bd1061998a501ee7d4b6d449020df3266ca3124b941ec56cf2005c3779ca142"
source = "git+https://github.com/clap-rs/clap?branch=master#65b3892ef6c1ddf0cf837c76d164b8182103fa5d"
dependencies = [
"bitflags",
"clap_derive",
@ -30,15 +29,13 @@ dependencies = [
"lazy_static",
"os_str_bytes",
"textwrap",
"unicode-width",
"vec_map",
]
[[package]]
name = "clap_derive"
version = "3.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "370f715b81112975b1b69db93e0b56ea4cd4e5002ac43b2da8474106a54096a1"
source = "git+https://github.com/clap-rs/clap?branch=master#65b3892ef6c1ddf0cf837c76d164b8182103fa5d"
dependencies = [
"heck",
"proc-macro-error",
@ -137,9 +134,9 @@ dependencies = [
[[package]]
name = "os_str_bytes"
version = "2.4.0"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afb2e1c3ee07430c2cf76151675e583e0f19985fa6efae47d6848a3e2c824f85"
checksum = "6acbef58a60fe69ab50510a55bc8cdd4d6cf2283d27ad338f54cb52747a9cf2d"
[[package]]
name = "proc-macro-error"
@ -213,12 +210,9 @@ dependencies = [
[[package]]
name = "textwrap"
version = "0.12.1"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789"
dependencies = [
"unicode-width",
]
checksum = "cd05616119e612a8041ef58f2b578906cc2531a6069047ae092cfb86a325d835"
[[package]]
name = "unicode-segmentation"
@ -226,12 +220,6 @@ version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
[[package]]
name = "unicode-width"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
[[package]]
name = "unicode-xid"
version = "0.2.2"

View File

@ -14,6 +14,8 @@ default-features = false
features = ["integer", "rational", "float"]
[dependencies.clap]
version = "3.0.0-beta.2"
#version = "3.0.0-beta.2" # Bug 2279
git = "https://github.com/clap-rs/clap"
branch = "master"
default-features = false
features = ["std", "derive"]

View File

@ -47,7 +47,7 @@ enum Command {
/// Count a single transferable vote (STV) election
#[derive(Clap)]
#[clap(setting=AppSettings::DeriveDisplayOrder, setting=AppSettings::UnifiedHelpMessage)]
#[clap(setting=AppSettings::DeriveDisplayOrder)]
struct STV {
// -- File input --
@ -57,25 +57,25 @@ struct STV {
// -- Numbers settings --
/// Numbers mode
#[clap(short, long, possible_values(&["rational", "float64"]), default_value="rational")]
#[clap(help_heading=Some("NUMBERS"), short, long, possible_values(&["rational", "float64"]), default_value="rational", value_name="mode")]
numbers: String,
// -- Rounding settings --
/// Round votes to specified decimal places
#[clap(long)]
#[clap(help_heading=Some("ROUNDING"), long, value_name="dps")]
round_votes: Option<usize>,
// -- Display settings --
/// Hide excluded candidates from results report
#[clap(long)]
#[clap(help_heading=Some("DISPLAY"), long)]
hide_excluded: bool,
/// Sort candidates by votes in results report
#[clap(long)]
#[clap(help_heading=Some("DISPLAY"), long)]
sort_votes: bool,
/// Print votes to specified decimal places in results report
#[clap(long, default_value="2")]
#[clap(help_heading=Some("DISPLAY"), long, default_value="2", value_name="dps")]
pp_decimals: usize,
}