Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Bump clap to 4.0.x and adjust to best practices #12381

Merged
merged 26 commits into from
Oct 18, 2022

Conversation

skunert
Copy link
Contributor

@skunert skunert commented Sep 28, 2022

Update to latest clap version.

Change Overview

  • arg_enum changed to value_enum, implementations of ArgEnum changed to ValueEnum
  • conflicts_with now needs the snake-case arguments (e.g. conflicts_with_all = ["json_input"] vs conflicts_with_all = ["json-input"])
  • multiple_values(true) is transformed to num_args = 0..
  • #[clap(possible_values = ["1", "2"])] transformed to #[arg(value_parser = PossibleValuesParser::new(["1", "2"])]
  • #[clap(parse(from_os_str))] is replaced by just #[arg()] due to changed defaults
  • parse = ... has been replaced by value_parser = ...
  • attribute macro clap was replaced
    • with value for enums
    • with arg for arguments
    • with command for commands

polkadot companion: paritytech/polkadot#6128
cumulus companion: paritytech/cumulus#1745

@skunert skunert added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Sep 28, 2022
@skunert skunert requested a review from a team September 28, 2022 14:24
@skunert skunert requested review from kianenigma and a team as code owners September 28, 2022 14:24
@skunert skunert marked this pull request as draft September 29, 2022 07:18
@skunert
Copy link
Contributor Author

skunert commented Sep 29, 2022

Converting to draft as clap 4.0 is already out, will update this PR

@skunert skunert changed the title Bump clap to 3.2.22 and adjust to best practices Bump clap to 4.0.9 and adjust to best practices Oct 7, 2022
@skunert skunert changed the title Bump clap to 4.0.9 and adjust to best practices Bump clap to 4.0.x and adjust to best practices Oct 9, 2022
bin/node-template/node/Cargo.toml Outdated Show resolved Hide resolved
bin/node/inspect/src/cli.rs Outdated Show resolved Hide resolved
client/cli/src/commands/run_cmd.rs Show resolved Hide resolved
client/cli/src/params/mod.rs Outdated Show resolved Hide resolved
utils/frame/benchmarking-cli/src/storage/cmd.rs Outdated Show resolved Hide resolved
skunert and others added 2 commits October 10, 2022 08:55
Co-authored-by: Bastian Köcher <git@kchr.de>
@skunert skunert requested a review from a team October 10, 2022 07:14
@skunert skunert marked this pull request as ready for review October 10, 2022 07:14
match self {
Self::Interpreted => write!(f, "Interpreted"),
Self::Compiled => write!(f, "Compiled"),
const INTERPRETED_NAME: &str = "interpreted-i-know-what-i-do";
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason why you added this const for the interpreted variant but not for the compiled one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The compiled one follows the name of the enum precisely. The interpreted one has this "interpreted-i-know-what-i-do" extra name. But yeah maybe not necessary.

client/cli/src/arg_enums.rs Outdated Show resolved Hide resolved
client/cli/src/params/network_params.rs Outdated Show resolved Hide resolved
@paritytech-ci paritytech-ci requested a review from a team October 17, 2022 18:36
@skunert
Copy link
Contributor Author

skunert commented Oct 18, 2022

bot merge

@paritytech-processbot paritytech-processbot bot merged commit e8a4408 into paritytech:master Oct 18, 2022
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
* Bump clap to 3.2.22

* Replace `from_os_str` with `value_parser`

* Replace `from_str` and `try_from_str` with `value_parser`

* Move possible_values to the new format

* Remove unwanted print

* Add missing match branch

* Update clap to 4.0.9 and make it compile

* Replace deprecated `clap` macro with `command` and `value`

* Move remaining `clap` attributes to `arg`

* Remove no-op value_parsers

* Adjust value_parser for state_version

* Remove "deprecated" feature flag and bump to 4.0.11

* Improve range

Co-authored-by: Bastian Köcher <git@kchr.de>

* Apply suggestions

* Trigger CI

* Fix unused error warning

* Fix doc errors

* Fix ArgGroup naming conflict

* Change default_value to default_value_t

* Use 1.. instead of 0..

Co-authored-by: Bastian Köcher <git@kchr.de>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
Status: done
Development

Successfully merging this pull request may close these issues.

6 participants