Skip to content

Commit 0902edc

Browse files
authored
Adjusting help message (#4865)
On stable, running with `--help|-h` shows information about `file-lines` which is a nightly-only option. This commit removes all mention of `file-lines` from the help message on stable. There is room for improvement here; perhaps a new struct called, e.g., `StableOptions` could be added to complement the existing `GetOptsOptions` struct. `StableOptions` could have a field for each field in `GetOptsOptions`, with each field's value being a `bool` that specifies whether or not the option exists on stable. Or is this adding too much complexity?
1 parent bc4c95f commit 0902edc

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Diff for: src/bin/main.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,15 @@ fn make_opts() -> Options {
178178
opts.optflag("v", "verbose", "Print verbose output");
179179
opts.optflag("q", "quiet", "Print less output");
180180
opts.optflag("V", "version", "Show version information");
181-
opts.optflagopt(
182-
"h",
183-
"help",
184-
"Show this message or help about a specific topic: `config` or `file-lines`",
185-
"=TOPIC",
186-
);
181+
let help_topics = if is_nightly {
182+
"`config` or `file-lines`"
183+
} else {
184+
"`config`"
185+
};
186+
let mut help_topic_msg = "Show this message or help about a specific topic: ".to_owned();
187+
help_topic_msg.push_str(help_topics);
188+
189+
opts.optflagopt("h", "help", &help_topic_msg, "=TOPIC");
187190

188191
opts
189192
}
@@ -437,7 +440,7 @@ fn determine_operation(matches: &Matches) -> Result<Operation, OperationError> {
437440
return Ok(Operation::Help(HelpOp::None));
438441
} else if topic == Some("config".to_owned()) {
439442
return Ok(Operation::Help(HelpOp::Config));
440-
} else if topic == Some("file-lines".to_owned()) {
443+
} else if topic == Some("file-lines".to_owned()) && is_nightly() {
441444
return Ok(Operation::Help(HelpOp::FileLines));
442445
} else {
443446
return Err(OperationError::UnknownHelpTopic(topic.unwrap()));

0 commit comments

Comments
 (0)