-
-
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
Deprecate Arg::help in favour of Arg::about [WIP] #1840
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far, keep it up!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see Arg::about
fn being added. Please rename Arg::help
fn to it and add a deprecated function:
pub fn help(mut self, h: &'help str) -> Self {
self.about(h)
}
Hey @pksunkara I have rebased and added more commits, but seems like this page not reflecting updates from arg_help branch. Update: Github was down |
So, there's one failing test on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You missed some changes in Arg::from_yaml
.
Could you also remove Arg::help
and Arg::long_help
descriptions?
clap_derive/src/derives/attrs.rs
Outdated
|| m.name == "long_help" | ||
|| m.name == "about" | ||
|| m.name == "long_about" | ||
m.name == "about" || m.name == "long_about" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to also keep the help
and long_help
here. That should fix the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added help
and long_help
back, but it still fails. Note that I had updated the test help_is_better_than_comments case to use about
attribute. So it shouldn't depend on help
; right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I misunderstood the test. This code is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But at the same time: top_long_doc_comment_both_help_long_help
test passes and it uses about
attribute, which is strange
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It uses a doc comment. Doc comments fly under help
and long_help
. Replace this
clap/clap_derive/src/derives/attrs.rs
Line 436 in 3de8af4
res.push_doc_comment(&field.attrs, "help"); |
With "about"
and it should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will take a look at this today and get back to you. Thanks for the patience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I found the issue. Attrs::from_field
calls this function. When about
is encountered, instead of pushing a method, we are assigning it to Attrs.about
here. So, later when we are searching for about
methods, we can't see the attribute because it's not a Method
in Attrs.methods
. You can fix this issue by removing about
from Attrs
and pushing the about
attribute as a method when parsing it.
You would probably have to change the order of these 2 lines afterwards. Similarly, with Attrs::from_field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can fix this issue by removing about from Attrs and pushing the about attribute as a method when parsing it.
No wait! I was the one who wrote this code and thought I don't remember particulars, I remember it was about something important.
I'll see what is it about tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked a bit and as far as I can see, it wasn't really needed. @creativcoder should be coming up with any issues if they pop up.
@creativcoder Also, you need to edit the benches
folder. They still have uses Arg::help
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember now: it was about no_version
. We removed this hack in clap_derive so it shuld be fine.
9c8c06d has commits only for handling |
Commit looks good |
Can we finish this up soon? I want to do some changes based on this. Thanks. |
@pksunkara remaining comments have been addressed. r?
Do you mean removing the docs over them? |
Looks good, just one final thing, you need to change |
Done |
bors r+ |
🕐 Waiting for PR status (Github check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set. |
👎 Rejected by PR status |
Please format your code and fix clippy warnings. |
bors r+ |
🕐 Waiting for PR status (Github check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set. |
bors r=pksunkara |
Build succeeded: |
This reverts commits 24cb8b1..d0abb37 from clap-rs/clap#1840
This reverts commits 24cb8b1..d0abb37 from clap-rs/clap#1840 This is part of #16. clap-rs/clap#1840 wasn't the right call but we don't have time to make the decision now, so instead of having one option and changing it in 4.0, this reverts back to clap2 behavior.
This reverts commits 24cb8b1..d0abb37 from clap-rs/clap#1840 This is part of #16. clap-rs/clap#1840 wasn't the right call but we don't have time to make the decision now, so instead of having one option and changing it in 4.0, this reverts back to clap2 behavior.
This reverts commits 24cb8b1..d0abb37 from clap-rs/clap#1840 This is part of #16. clap-rs/clap#1840 wasn't the right call but we don't have time to make the decision now, so instead of having one option and changing it in 4.0, this reverts back to clap2 behavior.
Taking this incrementally as this is a big refactor.
Change: Updated usage of
Arg::help
withArg::about
, deprecatinghelp
Closes #1823