about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMichael Murphy <m.b.murphy15@gmail.com>2021-06-11 02:39:28 +0100
committerCaleb Cartwright <calebcartwright@users.noreply.github.com>2021-07-25 22:53:32 -0500
commit486e774fbfbbe2be98cdd2ebdbfc3e8b92fc2a95 (patch)
tree58a23bf26dc0bd01439a870b9369e53622e20e4a /src
parent1ca3798d2c961c43b02e312e8aa0e4bfa3f1b37e (diff)
downloadrust-486e774fbfbbe2be98cdd2ebdbfc3e8b92fc2a95.tar.gz
rust-486e774fbfbbe2be98cdd2ebdbfc3e8b92fc2a95.zip
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?
Diffstat (limited to 'src')
-rw-r--r--src/bin/main.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/bin/main.rs b/src/bin/main.rs
index 92fe8b9c514..4b4aa42d935 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -178,12 +178,15 @@ fn make_opts() -> Options {
     opts.optflag("v", "verbose", "Print verbose output");
     opts.optflag("q", "quiet", "Print less output");
     opts.optflag("V", "version", "Show version information");
-    opts.optflagopt(
-        "h",
-        "help",
-        "Show this message or help about a specific topic: `config` or `file-lines`",
-        "=TOPIC",
-    );
+    let help_topics = if is_nightly {
+        "`config` or `file-lines`"
+    } else {
+        "`config`"
+    };
+    let mut help_topic_msg = "Show this message or help about a specific topic: ".to_owned();
+    help_topic_msg.push_str(help_topics);
+
+    opts.optflagopt("h", "help", &help_topic_msg, "=TOPIC");
 
     opts
 }
@@ -437,7 +440,7 @@ fn determine_operation(matches: &Matches) -> Result<Operation, OperationError> {
             return Ok(Operation::Help(HelpOp::None));
         } else if topic == Some("config".to_owned()) {
             return Ok(Operation::Help(HelpOp::Config));
-        } else if topic == Some("file-lines".to_owned()) {
+        } else if topic == Some("file-lines".to_owned()) && is_nightly() {
             return Ok(Operation::Help(HelpOp::FileLines));
         } else {
             return Err(OperationError::UnknownHelpTopic(topic.unwrap()));