Skip to content
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

Merged
merged 8 commits into from
Apr 27, 2020

Conversation

creativcoder
Copy link
Contributor

@creativcoder creativcoder commented Apr 19, 2020

Taking this incrementally as this is a big refactor.
Change: Updated usage of Arg::help with Arg::about, deprecating help

Closes #1823

Copy link
Contributor

@CreepySkeleton CreepySkeleton left a 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!

src/build/arg/mod.rs Outdated Show resolved Hide resolved
src/build/arg/mod.rs Outdated Show resolved Hide resolved
src/build/arg/mod.rs Outdated Show resolved Hide resolved
src/build/arg/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@pksunkara pksunkara left a 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)
}

@creativcoder
Copy link
Contributor Author

creativcoder commented Apr 21, 2020

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

@creativcoder
Copy link
Contributor Author

So, there's one failing test on the clap_derive crate in doc-comments-help.rs
I have renamed usage of "help" in clap_derive to "about" where I felt it was applicable. Anything else that I missed?

Copy link
Member

@pksunkara pksunkara left a 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?

|| m.name == "long_help"
|| m.name == "about"
|| m.name == "long_about"
m.name == "about" || m.name == "long_about"
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor

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

res.push_doc_comment(&field.attrs, "help");

With "about" and it should work.

Copy link
Member

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.

Copy link
Member

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

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor

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.

src/build/arg/mod.rs Show resolved Hide resolved
src/build/arg/mod.rs Show resolved Hide resolved
src/build/arg/mod.rs Show resolved Hide resolved
src/build/arg/mod.rs Show resolved Hide resolved
src/build/arg/mod.rs Show resolved Hide resolved
src/build/arg/mod.rs Outdated Show resolved Hide resolved
src/build/arg/mod.rs Outdated Show resolved Hide resolved
clap_derive/src/derives/attrs.rs Show resolved Hide resolved
@creativcoder creativcoder mentioned this pull request Apr 26, 2020
@creativcoder
Copy link
Contributor Author

9c8c06d has commits only for handling about method resolution. @pksunkara r? Will make changes for remaining comments after this.

@pksunkara
Copy link
Member

Commit looks good

@pksunkara
Copy link
Member

Can we finish this up soon? I want to do some changes based on this. Thanks.

@creativcoder
Copy link
Contributor Author

@pksunkara remaining comments have been addressed. r?

Could you also remove Arg::help and Arg::long_help descriptions?

Do you mean removing the docs over them?

@pksunkara
Copy link
Member

Looks good, just one final thing, you need to change help in https://github.com/clap-rs/clap/blob/master/tests/fixtures/app.yml to about. Similarly, https://github.com/clap-rs/clap/blob/master/tests/fixtures/app_2space.yml

@creativcoder
Copy link
Contributor Author

Done

@pksunkara
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Apr 27, 2020

🕐 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
Copy link
Contributor

bors bot commented Apr 27, 2020

👎 Rejected by PR status

@pksunkara
Copy link
Member

Please format your code and fix clippy warnings.

@pksunkara
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Apr 27, 2020

🕐 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.

@CreepySkeleton
Copy link
Contributor

bors r=pksunkara

@bors
Copy link
Contributor

bors bot commented Apr 27, 2020

Build succeeded:

@bors bors bot merged commit 4675070 into clap-rs:master Apr 27, 2020
epage added a commit to epage/clapng that referenced this pull request Nov 18, 2021
epage added a commit to epage/clapng that referenced this pull request Nov 18, 2021
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.
epage added a commit to epage/clapng that referenced this pull request Nov 18, 2021
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.
epage added a commit to epage/clapng that referenced this pull request Nov 18, 2021
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename Arg::help to Arg::about
3 participants