From e7596f0276c212ea4d0a5fc4831428aaefff486c Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Thu, 9 Jun 2022 18:32:09 -0400 Subject: [PATCH] Add help messages --- src/set.rs | 11 +++++++++-- src/sort.rs | 17 ++++++++++------- src/trim.rs | 10 +++++++--- src/uniq.rs | 6 +++--- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/set.rs b/src/set.rs index 83b3b74..649295a 100644 --- a/src/set.rs +++ b/src/set.rs @@ -11,10 +11,17 @@ use std::{collections::HashSet, io::Write, str::FromStr}; #[derive(clap::StructOpt, Debug)] pub struct Options { - #[clap(min_values = 1, max_values = 3)] + #[clap( + min_values = 1, + max_values = 3, + help = "Register operation and operand. Empty register is current selection. Example: 'a-b' or '+b'" + )] args: Vec, - #[clap(short = 'T')] + #[clap( + short = 'T', + help = "Do not trim the selections before doing set operations" + )] no_trim: bool, // #[clap(short, long)] // regex: Option, diff --git a/src/sort.rs b/src/sort.rs index 50b0b25..fbfc513 100644 --- a/src/sort.rs +++ b/src/sort.rs @@ -5,20 +5,23 @@ use std::{cmp::Ordering, io::Write}; #[derive(clap::StructOpt, Debug)] pub struct Options { - #[clap(index = 1)] + #[clap(index = 1, help = "Optional regex comparison key")] regex: Option, - #[clap(short = 's', long)] + #[clap( + short = 's', + long, + help = "Optional register for using subselection ma tching" + )] subselections_register: Option, // TODO: Can we invert a boolean? This name is terrible - #[clap(short = 'S', long, parse(try_from_str = invert_bool), default_value_t)] + #[clap(short = 'S', long, parse(try_from_str = invert_bool), default_value_t, help = "Do not treat trimmed value of selections when sorting")] no_skip_whitespace: bool, - #[clap(short, long)] + #[clap(short, long, help = "Sort numbers lexicographically")] lexicographic_sort: bool, - #[clap(short, long)] + #[clap(short, long, help = "Reverse sorting")] reverse: bool, - #[clap(short, long)] + #[clap(short, long, help = "Ignore case when sorting")] ignore_case: bool, - // TODO: Sort by character ([xba] => [abx]) } fn invert_bool(s: &str) -> Result { diff --git a/src/trim.rs b/src/trim.rs index 5e20304..facee17 100644 --- a/src/trim.rs +++ b/src/trim.rs @@ -3,11 +3,15 @@ use std::io::Write; #[derive(clap::StructOpt, Debug)] pub struct Options { - #[clap(short, long)] + #[clap(short, long, help = "Trim from left")] left: bool, - #[clap(short, long)] + #[clap(short, long, help = "Trim right side")] right: bool, - #[clap(short, long)] + #[clap( + short, + long, + help = "If selection ends in a newline, do not add the newline back after trimming" + )] no_preserve_newline: bool, } diff --git a/src/uniq.rs b/src/uniq.rs index 6e391ec..1a87d3c 100644 --- a/src/uniq.rs +++ b/src/uniq.rs @@ -8,12 +8,12 @@ use std::collections::BTreeSet; #[derive(clap::StructOpt, Debug)] pub struct Options { - #[clap(index = 1)] + #[clap(index = 1, help = "Optional regex to compare unique elements")] regex: Option, - #[clap(short, long)] + #[clap(short, long, help = "Ignore the case when comparing")] ignore_case: bool, // TODO: Can we invert a boolean? This name is terrible - #[clap(short = 'S', long)] + #[clap(short = 'S', long, help = "Do not skip whitespace when comparing")] no_skip_whitespace: bool, } pub fn uniq(options: &Options) -> Result {