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

fix: Ease clap2->clap3 migration with deprecations #2718

Merged
merged 1 commit into from
Oct 16, 2021
Merged

Conversation

epage
Copy link
Member

@epage epage commented Aug 18, 2021

This was done based on the README. I've not done a deep dive of the docs to see what might have been missed.

  • App::with_defaults was not included since that has been deprecated
    since 2.14
  • App::args_from_usage does not have a close enough parallel in the
    new API, as far as I could tell
  • ArgMatches::usage cannot have a thin wrapper around
    App::generate_usage.
  • App::write_*: getting lazy, didn't seem like high value functions
  • Any Settings (some things need to be figured out here)

This is a part of #2617

@epage
Copy link
Member Author

epage commented Sep 8, 2021

@pksunkara any update on this? It passes CI, just re-pushed as part of rebase

@pksunkara
Copy link
Member

I am waiting on this because we have to finalize the discussion on #2617

@epage
Copy link
Member Author

epage commented Oct 12, 2021

Looks like we agreed in #2617 on this direction. Going ahead with a post-merge review.

bors r+

@epage epage added the M-unreviewed Meta: Request for post-merge review. label Oct 12, 2021
bors bot added a commit that referenced this pull request Oct 12, 2021
2718: fix: Ease clap2->clap3 migration with deprecations r=epage a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
@pksunkara
Copy link
Member

I don't think we agreed on there, right? At least that's the impression I get. Can we please wait on this a bit more? There is no need for urgency

@epage
Copy link
Member Author

epage commented Oct 12, 2021

bors r-

@bors
Copy link
Contributor

bors bot commented Oct 12, 2021

Canceled.

@epage
Copy link
Member Author

epage commented Oct 12, 2021

I don't think we agreed on there, right? At least that's the impression I get. Can we please wait on this a bit more?

@kbknapp seemed in favor of this 10 days ago and I hadn't seen a post from you.

There is no need for urgency

This has been open for 2 months. I have to deal with merge conflicts, designs are blocked on a decision, and mental state gets lost, like with #2721. We can't just let these things be left around.

- `App::with_defaults` was not included since that has been deprecated
  since 2.14
- `App::args_from_usage` does not have a close enough parallel in the
  new API, as far as I could tell
- `ArgMatches::usage` cannot have a thin wrapper around
  `App::generate_usage`.
- `App::write_*`: getting lazy, didn't seem like high value functions
- Any `Settings` (some things need to be figured out here)

This is a part of clap-rs#2617
epage added a commit to epage/clap that referenced this pull request Oct 16, 2021
This gives users the basic error template for quick and dirty messages.
In addition to the lack of customization, they are not given anything to help
them with coloring or for programmayic use (info, source).

This is something I've wanted many times for one-off validation that
can't be expressed with clap's validation or it just wasn't worth
the hoops.  The more pressing need is for clap-rs#2255, I need `clap_derive`
to be able to create error messages and `Error::with_description` seemed
too disjoint from the rest of the clap experience that it seemed like
users would immediately create issues about it showing up.

With this available, I've gone ahead and deprecated
`Error::with_description`, assuming this will be sufficient for users
needs (or they can use IO Errors as a back door).  I did so according to
the pattern in clap-rs#2718 despite us not being fully resolved on that
approach yet.
epage added a commit to epage/clap that referenced this pull request Oct 16, 2021
This gives users the basic error template for quick and dirty messages.
In addition to the lack of customization, they are not given anything to help
them with coloring or for programmayic use (info, source).

This is something I've wanted many times for one-off validation that
can't be expressed with clap's validation or it just wasn't worth
the hoops.  The more pressing need is for clap-rs#2255, I need `clap_derive`
to be able to create error messages and `Error::with_description` seemed
too disjoint from the rest of the clap experience that it seemed like
users would immediately create issues about it showing up.

With this available, I've gone ahead and deprecated
`Error::with_description` (added in 58512f2), assuming this will be
sufficient for users needs (or they can use IO Errors as a back door).
I did so according to the pattern in clap-rs#2718 despite us not being fully
resolved on that approach yet.
epage added a commit to epage/clap that referenced this pull request Oct 16, 2021
This gives users the basic error template for quick and dirty messages.
In addition to the lack of customization, they are not given anything to help
them with coloring or for programmayic use (info, source).

This is something I've wanted many times for one-off validation that
can't be expressed with clap's validation or it just wasn't worth
the hoops.  The more pressing need is for clap-rs#2255, I need `clap_derive`
to be able to create error messages and `Error::with_description` seemed
too disjoint from the rest of the clap experience that it seemed like
users would immediately create issues about it showing up.

With this available, I've gone ahead and deprecated
`Error::with_description` (added in 58512f2), assuming this will be
sufficient for users needs (or they can use IO Errors as a back door).
I did so according to the pattern in clap-rs#2718 despite us not being fully
resolved on that approach yet.
@epage
Copy link
Member Author

epage commented Oct 16, 2021

bors r+

@pksunkara pksunkara removed the M-unreviewed Meta: Request for post-merge review. label Oct 16, 2021
epage added a commit to epage/clap that referenced this pull request Oct 16, 2021
This gives users the basic error template for quick and dirty messages.
In addition to the lack of customization, they are not given anything to help
them with coloring or for programmayic use (info, source).

This is something I've wanted many times for one-off validation that
can't be expressed with clap's validation or it just wasn't worth
the hoops.  The more pressing need is for clap-rs#2255, I need `clap_derive`
to be able to create error messages and `Error::with_description` seemed
too disjoint from the rest of the clap experience that it seemed like
users would immediately create issues about it showing up.

With this available, I've gone ahead and deprecated
`Error::with_description` (added in 58512f2), assuming this will be
sufficient for users needs (or they can use IO Errors as a back door).
I did so according to the pattern in clap-rs#2718 despite us not being fully
resolved on that approach yet.
@bors
Copy link
Contributor

bors bot commented Oct 16, 2021

Build succeeded:

@bors bors bot merged commit 8647302 into clap-rs:master Oct 16, 2021
@epage epage deleted the 2to3 branch October 16, 2021 20:51
epage added a commit to epage/clap that referenced this pull request Oct 17, 2021
This gives users the basic error template for quick and dirty messages.
In addition to the lack of customization, they are not given anything to help
them with coloring or for programmayic use (info, source).

This is something I've wanted many times for one-off validation that
can't be expressed with clap's validation or it just wasn't worth
the hoops.  The more pressing need is for clap-rs#2255, I need `clap_derive`
to be able to create error messages and `Error::with_description` seemed
too disjoint from the rest of the clap experience that it seemed like
users would immediately create issues about it showing up.

With this available, I've gone ahead and deprecated
`Error::with_description` (added in 58512f2), assuming this will be
sufficient for users needs (or they can use IO Errors as a back door).
I did so according to the pattern in clap-rs#2718 despite us not being fully
resolved on that approach yet.
/// Deprecated, see [`Arg::forbid_empty_values`]
#[deprecated(since = "3.0.0", note = "Replaced with `Arg::forbid_empty_values`")]
pub fn empty_values(self, empty: bool) -> Self {
self.forbid_empty_values(!empty)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct btw, Check the old code in v2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, when you see a problem, say what the problem is, rather than requiring the person to diff to very different code bases in hopes of seeing what the difference was.

From my reading of clap2, I have not seen what is incorrect about it. I'm glad you identified a problem but please help out and say what it is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sometimes forget that you don't have the context for what we changed.

Here's the old code which was actually leading to bugs, https://docs.rs/clap/2.33.3/src/clap/args/arg.rs.html#2297-2304.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me double check, you are trying to call out that this is missing the "forbidding empty values implies taking a value" part?

If so, I'll get that noted on #2617 to be looked at as part of the wider inference look.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

I'll get that noted on #2617 to be looked at as part of the wider inference look.

What do you mean by that? In case you mean that we want to add inference back into the settings, then I disagree because that caused a lot of bugs.

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.

2 participants