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

View File

@ -14,6 +14,8 @@ default-features = false
features = ["integer", "rational", "float"] features = ["integer", "rational", "float"]
[dependencies.clap] [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 default-features = false
features = ["std", "derive"] features = ["std", "derive"]

View File

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