( )⚙ D10080 rhg: Use clap’s support for global CLI arguments

This is an archive of the discontinued Mercurial Phabricator instance.

rhg: Use clap’s support for global CLI arguments
ClosedPublic

Authored by SimonSapin on Feb 26 2021, 6:17 AM.

Details

Summary

By default, clap only accepts app-level arguments (as opposed to sub-command
level) to be specified before a sub-command: rhg -R ./foo log. Specifying
them after would be rejected: rhg log -R ./foo.

Previously we worked around that by registering global arguments both
at the app level and on each sub-command, but that required looking
for their value in two places. It turns out that Clap has built-in support
for what we want to do, so let’s use it.

Also, Clap "settings" turn out to be either global or not too.
Let’s make AllowInvalidUtf8 apply to sub-commands too.

Diff Detail

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

Event Timeline

SimonSapin created this revision.Feb 26 2021, 6:17 AM
baymax edited the summary of this revision. (Show Details)Feb 26 2021, 7:11 AM
baymax updated this revision to Diff 25977.

✅ refresh by Heptapod after a successful CI run (🐙 💚)

martinvonz accepted this revision.Feb 26 2021, 1:31 PM
martinvonz added a subscriber: martinvonz.

Good find! :)

This revision is now accepted and ready to land.Feb 26 2021, 1:31 PM
This revision was automatically updated to reflect the committed changes.