This is an archive of the discontinued Mercurial Phabricator instance.

rust: upgrade to Clap 3
Needs RevisionPublic

Authored by martinvonz on Jan 14 2022, 5:21 PM.

Details

Reviewers
Alphare
Group Reviewers
hg-reviewers
Summary

Clap 3 was released about a week ago. Let's stay up to date.

Some changes worth mentioning:

  • AppSettings::VersionlessSubcommands is on by default and deleted
  • AllowInvalidUtf8 moved from AppSettings to ArgSettings. I set it only on the global args (-R, --config, --cwd). The other commands don't actually support invalid UTF-8, despite the setting being on at the top level. I'll leave it to someone else to switch to value[s]_of_os() and enable AllowInvalidUtf8 on remaining arguments (where appropriate).
  • Arg::short() now takes a single character (used to take a string). That makes the leading dashes we have on strings passed to Arg::long() stand out (to me at least). I'll leave it to someone else to drop them if they care.

Diff Detail

Repository
rHG Mercurial
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

martinvonz created this revision.Jan 14 2022, 5:21 PM
Alphare requested changes to this revision.Jan 17 2022, 5:04 AM
Alphare added a subscriber: Alphare.

Unfortunately we can't move forward with clap version 3 since it requires a version of Rust that is too recent for our policy. https://github.com/clap-rs/clap/blob/master/CHANGELOG.md#minimum-required-rust

I was looking into the only change that seems like it might cause an issue (the invalid utf8 stuff), and this patch just wouldn't compile under 1.48.0. We're going to have to wait until Debian Bookworm releases.

This revision now requires changes to proceed.Jan 17 2022, 5:04 AM