-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--help message randomly show and hide docs lines #2983
Comments
Sent here by @epage, issue happened in this piece of code in one of my projects. |
Which empty comment? |
(first step) // Ouch commands:
// - `compress`
// - `decompress`
// - `list`
//
// Clap commands:
// - `help`
/// Repository: https://github.com/ouch-org/ouch (second step) /// Ouch commands:
/// - `compress`
/// - `decompress`
/// - `list`
///
/// Clap commands:
/// - `help`
/// Repository: https://github.com/ouch-org/ouch @epage then you delete that "///" blank line at the middle, leaving this: (third step) /// Ouch commands:
/// - `compress`
/// - `decompress`
/// - `list`
/// Clap commands:
/// - `help`
/// Repository: https://github.com/ouch-org/ouch Sorry for the confusion, this bug has too many steps to reproduce, maybe I even reported more than one bug at the same time. |
Ok, let's break down all of the parts
Ok, I think I covered it all The challenge is in solutions because we can't introspect across items
|
Looks like if we always set
This might be a good enough workaround until we can get a better solution. |
My current proposal is
|
I am confused by your proposal. How does that solve this issue? |
There are two framings for this problem
This is bigger and riskier.
We end up with app
.about(subcommand_doc_comment_summary)
.long_about(subcommand_doc_comment)
.about(parser_doc_comment_summary) My proposal is to switch us to app
.about(subcommand_doc_comment_summary)
.long_about(subcommand_doc_comment)
.about(parser_doc_comment_summary)
.long_about(None) // resets the field to default By us always pairing them together when applying doc comments, we get a more consistent experience. Granted, there is still |
#3175 shows what I'm talking about. I even have a distinct commit for the test passing with the broken behavior before I change it so it passes with the correct behavior. |
The main care about is that when we override a `flatten` / `subcommand` doc comment in a parent container, that we make sure we take nothing from the child container, rather than implicitly taking one `about` ut not `long_about`. To do this, and to play the most safe with long help detection, we reset `long_about` to default when there is no doc comment body to use for `long_about`. Fixes clap-rs#2983
From @pksunkara in #3175
Earlier I had commented that #2894 is "This is bigger and riskier.". As I mentioned in #2894, there are some settings that are coupled to a Similarly, for I'm concerned that trying to manage what can and can't be set in a So I wonder if we should reject #2894. We can go on for a while debating and deciding what to do about #2894. Its a big enough decision to commit to doing #2894 that I don't want to block other improvements on it. In addition, I'd like to see more of the API become consistent, as I mentioned in the commit message that changed the API. We already support |
Please complete the following tasks
Rust Version
rustc 1.58.0-nightly (e249ce6b2 2021-10-30)
Clap Version
3.0.0-beta.5
Minimal reproducible code
Steps to reproduce the bug with the above code
cargo run -q -- --help
Actual Behaviour
This is a tricky one, if you copy my code example, here is the --help message:
So, that
Repository
line does not appear in the help message 👎, but if we change all the//
comments to be///
(to three slashes):Now it appears!! 👍.
Now try deleting the empty comment
"///\n"
. Does not appear anymore 👎.Now you delete the
#[clap(version, about)]
line. Appears again 👍.So, we went 👎 -> 👍 -> 👎 -> 👍 just by making small random changes.
Expected Behaviour
I assume it should be consistent and always show that repository line.
Additional Context
No response
Debug Output
With the starter code:
The text was updated successfully, but these errors were encountered: