mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-06-26 20:17:52 +00:00
subcmds: delete redundant dest= settings
Add a test to enforce this too. Change-Id: I80b5cf567aa33db9c24b53428c66d69f9c1d8d74 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/478481 Commit-Queue: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Scott Lee <ddoman@google.com>
This commit is contained in:
@ -48,7 +48,6 @@ It is equivalent to "git branch -D <branchname>".
|
|||||||
def _Options(self, p):
|
def _Options(self, p):
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--all",
|
"--all",
|
||||||
dest="all",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="delete all branches in all projects",
|
help="delete all branches in all projects",
|
||||||
)
|
)
|
||||||
|
@ -35,7 +35,6 @@ to the Unix 'patch' command.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-u",
|
"-u",
|
||||||
"--absolute",
|
"--absolute",
|
||||||
dest="absolute",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="paths are relative to the repository root",
|
help="paths are relative to the repository root",
|
||||||
)
|
)
|
||||||
|
@ -67,7 +67,9 @@ synced and their revisions won't be found.
|
|||||||
|
|
||||||
def _Options(self, p):
|
def _Options(self, p):
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--raw", dest="raw", action="store_true", help="display raw diff"
|
"--raw",
|
||||||
|
action="store_true",
|
||||||
|
help="display raw diff",
|
||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--no-color",
|
"--no-color",
|
||||||
@ -78,7 +80,6 @@ synced and their revisions won't be found.
|
|||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--pretty-format",
|
"--pretty-format",
|
||||||
dest="pretty_format",
|
|
||||||
action="store",
|
action="store",
|
||||||
metavar="<FORMAT>",
|
metavar="<FORMAT>",
|
||||||
help="print the log using a custom git pretty format string",
|
help="print the log using a custom git pretty format string",
|
||||||
|
@ -60,7 +60,6 @@ If no project is specified try to use current directory as a project.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-r",
|
"-r",
|
||||||
"--revert",
|
"--revert",
|
||||||
dest="revert",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="revert instead of checkout",
|
help="revert instead of checkout",
|
||||||
)
|
)
|
||||||
|
@ -133,7 +133,7 @@ without iterating through the remaining projects.
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _cmd_option(option, _opt_str, _value, parser):
|
def _cmd_option(option, _opt_str, _value, parser):
|
||||||
setattr(parser.values, option.dest, list(parser.rargs))
|
setattr(parser.values, option.dest or "command", list(parser.rargs))
|
||||||
while parser.rargs:
|
while parser.rargs:
|
||||||
del parser.rargs[0]
|
del parser.rargs[0]
|
||||||
|
|
||||||
@ -141,7 +141,6 @@ without iterating through the remaining projects.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-r",
|
"-r",
|
||||||
"--regex",
|
"--regex",
|
||||||
dest="regex",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="execute the command only on projects matching regex or "
|
help="execute the command only on projects matching regex or "
|
||||||
"wildcard expression",
|
"wildcard expression",
|
||||||
@ -149,7 +148,6 @@ without iterating through the remaining projects.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-i",
|
"-i",
|
||||||
"--inverse-regex",
|
"--inverse-regex",
|
||||||
dest="inverse_regex",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="execute the command only on projects not matching regex or "
|
help="execute the command only on projects not matching regex or "
|
||||||
"wildcard expression",
|
"wildcard expression",
|
||||||
@ -157,7 +155,6 @@ without iterating through the remaining projects.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-g",
|
"-g",
|
||||||
"--groups",
|
"--groups",
|
||||||
dest="groups",
|
|
||||||
help="execute the command only on projects matching the specified "
|
help="execute the command only on projects matching the specified "
|
||||||
"groups",
|
"groups",
|
||||||
)
|
)
|
||||||
@ -165,14 +162,12 @@ without iterating through the remaining projects.
|
|||||||
"-c",
|
"-c",
|
||||||
"--command",
|
"--command",
|
||||||
help="command (and arguments) to execute",
|
help="command (and arguments) to execute",
|
||||||
dest="command",
|
|
||||||
action="callback",
|
action="callback",
|
||||||
callback=self._cmd_option,
|
callback=self._cmd_option,
|
||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"-e",
|
"-e",
|
||||||
"--abort-on-errors",
|
"--abort-on-errors",
|
||||||
dest="abort_on_errors",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="abort if a command exits unsuccessfully",
|
help="abort if a command exits unsuccessfully",
|
||||||
)
|
)
|
||||||
|
@ -120,7 +120,6 @@ contain a line that matches both expressions:
|
|||||||
g.add_option(
|
g.add_option(
|
||||||
"-r",
|
"-r",
|
||||||
"--revision",
|
"--revision",
|
||||||
dest="revision",
|
|
||||||
action="append",
|
action="append",
|
||||||
metavar="TREEish",
|
metavar="TREEish",
|
||||||
help="Search TREEish, instead of the work tree",
|
help="Search TREEish, instead of the work tree",
|
||||||
|
@ -43,14 +43,12 @@ class Info(PagedCommand):
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-o",
|
"-o",
|
||||||
"--overview",
|
"--overview",
|
||||||
dest="overview",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="show overview of all local commits",
|
help="show overview of all local commits",
|
||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"-c",
|
"-c",
|
||||||
"--current-branch",
|
"--current-branch",
|
||||||
dest="current_branch",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="consider only checked out branches",
|
help="consider only checked out branches",
|
||||||
)
|
)
|
||||||
|
@ -40,7 +40,6 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-r",
|
"-r",
|
||||||
"--regex",
|
"--regex",
|
||||||
dest="regex",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="filter the project list based on regex or wildcard matching "
|
help="filter the project list based on regex or wildcard matching "
|
||||||
"of strings",
|
"of strings",
|
||||||
@ -48,7 +47,6 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-g",
|
"-g",
|
||||||
"--groups",
|
"--groups",
|
||||||
dest="groups",
|
|
||||||
help="filter the project list based on the groups the project is "
|
help="filter the project list based on the groups the project is "
|
||||||
"in",
|
"in",
|
||||||
)
|
)
|
||||||
@ -61,21 +59,18 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-n",
|
"-n",
|
||||||
"--name-only",
|
"--name-only",
|
||||||
dest="name_only",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="display only the name of the repository",
|
help="display only the name of the repository",
|
||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"-p",
|
"-p",
|
||||||
"--path-only",
|
"--path-only",
|
||||||
dest="path_only",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="display only the path of the repository",
|
help="display only the path of the repository",
|
||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"-f",
|
"-f",
|
||||||
"--fullpath",
|
"--fullpath",
|
||||||
dest="fullpath",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="display the full work tree path instead of the relative path",
|
help="display the full work tree path instead of the relative path",
|
||||||
)
|
)
|
||||||
|
@ -134,7 +134,6 @@ human-readable variations.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-o",
|
"-o",
|
||||||
"--output-file",
|
"--output-file",
|
||||||
dest="output_file",
|
|
||||||
default="-",
|
default="-",
|
||||||
help="file to save the manifest to. (Filename prefix for "
|
help="file to save the manifest to. (Filename prefix for "
|
||||||
"multi-tree.)",
|
"multi-tree.)",
|
||||||
|
@ -37,7 +37,6 @@ are displayed.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-c",
|
"-c",
|
||||||
"--current-branch",
|
"--current-branch",
|
||||||
dest="current_branch",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="consider only checked out branches",
|
help="consider only checked out branches",
|
||||||
)
|
)
|
||||||
|
@ -47,21 +47,18 @@ branch but need to incorporate new upstream changes "underneath" them.
|
|||||||
g.add_option(
|
g.add_option(
|
||||||
"-i",
|
"-i",
|
||||||
"--interactive",
|
"--interactive",
|
||||||
dest="interactive",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="interactive rebase (single project only)",
|
help="interactive rebase (single project only)",
|
||||||
)
|
)
|
||||||
|
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--fail-fast",
|
"--fail-fast",
|
||||||
dest="fail_fast",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="stop rebasing after first error is hit",
|
help="stop rebasing after first error is hit",
|
||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"-f",
|
"-f",
|
||||||
"--force-rebase",
|
"--force-rebase",
|
||||||
dest="force_rebase",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="pass --force-rebase to git rebase",
|
help="pass --force-rebase to git rebase",
|
||||||
)
|
)
|
||||||
@ -74,27 +71,23 @@ branch but need to incorporate new upstream changes "underneath" them.
|
|||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--autosquash",
|
"--autosquash",
|
||||||
dest="autosquash",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="pass --autosquash to git rebase",
|
help="pass --autosquash to git rebase",
|
||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--whitespace",
|
"--whitespace",
|
||||||
dest="whitespace",
|
|
||||||
action="store",
|
action="store",
|
||||||
metavar="WS",
|
metavar="WS",
|
||||||
help="pass --whitespace to git rebase",
|
help="pass --whitespace to git rebase",
|
||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--auto-stash",
|
"--auto-stash",
|
||||||
dest="auto_stash",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="stash local modifications before starting",
|
help="stash local modifications before starting",
|
||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"-m",
|
"-m",
|
||||||
"--onto-manifest",
|
"--onto-manifest",
|
||||||
dest="onto_manifest",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="rebase onto the manifest version instead of upstream "
|
help="rebase onto the manifest version instead of upstream "
|
||||||
"HEAD (this helps to make sure the local tree stays "
|
"HEAD (this helps to make sure the local tree stays "
|
||||||
|
@ -54,7 +54,6 @@ need to be performed by an end-user.
|
|||||||
)
|
)
|
||||||
g.add_option(
|
g.add_option(
|
||||||
"--repo-upgraded",
|
"--repo-upgraded",
|
||||||
dest="repo_upgraded",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help=optparse.SUPPRESS_HELP,
|
help=optparse.SUPPRESS_HELP,
|
||||||
)
|
)
|
||||||
|
@ -46,7 +46,6 @@ The '%prog' command stages files to prepare the next commit.
|
|||||||
g.add_option(
|
g.add_option(
|
||||||
"-i",
|
"-i",
|
||||||
"--interactive",
|
"--interactive",
|
||||||
dest="interactive",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="use interactive staging",
|
help="use interactive staging",
|
||||||
)
|
)
|
||||||
|
@ -51,7 +51,6 @@ revision specified in the manifest.
|
|||||||
def _Options(self, p):
|
def _Options(self, p):
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--all",
|
"--all",
|
||||||
dest="all",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="begin branch in all projects",
|
help="begin branch in all projects",
|
||||||
)
|
)
|
||||||
|
@ -82,7 +82,6 @@ the following meanings:
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-o",
|
"-o",
|
||||||
"--orphans",
|
"--orphans",
|
||||||
dest="orphans",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="include objects in working directory outside of repo "
|
help="include objects in working directory outside of repo "
|
||||||
"projects",
|
"projects",
|
||||||
|
@ -373,19 +373,16 @@ later is required to fix a server side protocol bug.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-f",
|
"-f",
|
||||||
"--force-broken",
|
"--force-broken",
|
||||||
dest="force_broken",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="obsolete option (to be deleted in the future)",
|
help="obsolete option (to be deleted in the future)",
|
||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--fail-fast",
|
"--fail-fast",
|
||||||
dest="fail_fast",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="stop syncing after first error is hit",
|
help="stop syncing after first error is hit",
|
||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--force-sync",
|
"--force-sync",
|
||||||
dest="force_sync",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="overwrite an existing git directory if it needs to "
|
help="overwrite an existing git directory if it needs to "
|
||||||
"point to a different object directory. WARNING: this "
|
"point to a different object directory. WARNING: this "
|
||||||
@ -393,7 +390,6 @@ later is required to fix a server side protocol bug.
|
|||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--force-checkout",
|
"--force-checkout",
|
||||||
dest="force_checkout",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="force checkout even if it results in throwing away "
|
help="force checkout even if it results in throwing away "
|
||||||
"uncommitted modifications. "
|
"uncommitted modifications. "
|
||||||
@ -401,7 +397,6 @@ later is required to fix a server side protocol bug.
|
|||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--force-remove-dirty",
|
"--force-remove-dirty",
|
||||||
dest="force_remove_dirty",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="force remove projects with uncommitted modifications if "
|
help="force remove projects with uncommitted modifications if "
|
||||||
"projects no longer exist in the manifest. "
|
"projects no longer exist in the manifest. "
|
||||||
@ -409,7 +404,6 @@ later is required to fix a server side protocol bug.
|
|||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--rebase",
|
"--rebase",
|
||||||
dest="rebase",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="rebase local commits regardless of whether they are "
|
help="rebase local commits regardless of whether they are "
|
||||||
"published",
|
"published",
|
||||||
@ -417,7 +411,6 @@ later is required to fix a server side protocol bug.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-l",
|
"-l",
|
||||||
"--local-only",
|
"--local-only",
|
||||||
dest="local_only",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="only update working tree, don't fetch",
|
help="only update working tree, don't fetch",
|
||||||
)
|
)
|
||||||
@ -433,7 +426,6 @@ later is required to fix a server side protocol bug.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-n",
|
"-n",
|
||||||
"--network-only",
|
"--network-only",
|
||||||
dest="network_only",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="fetch only, don't update working tree",
|
help="fetch only, don't update working tree",
|
||||||
)
|
)
|
||||||
@ -460,7 +452,6 @@ later is required to fix a server side protocol bug.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-m",
|
"-m",
|
||||||
"--manifest-name",
|
"--manifest-name",
|
||||||
dest="manifest_name",
|
|
||||||
help="temporary manifest to use for this sync",
|
help="temporary manifest to use for this sync",
|
||||||
metavar="NAME.xml",
|
metavar="NAME.xml",
|
||||||
)
|
)
|
||||||
@ -479,19 +470,16 @@ later is required to fix a server side protocol bug.
|
|||||||
"-u",
|
"-u",
|
||||||
"--manifest-server-username",
|
"--manifest-server-username",
|
||||||
action="store",
|
action="store",
|
||||||
dest="manifest_server_username",
|
|
||||||
help="username to authenticate with the manifest server",
|
help="username to authenticate with the manifest server",
|
||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"-p",
|
"-p",
|
||||||
"--manifest-server-password",
|
"--manifest-server-password",
|
||||||
action="store",
|
action="store",
|
||||||
dest="manifest_server_password",
|
|
||||||
help="password to authenticate with the manifest server",
|
help="password to authenticate with the manifest server",
|
||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--fetch-submodules",
|
"--fetch-submodules",
|
||||||
dest="fetch_submodules",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="fetch submodules from server",
|
help="fetch submodules from server",
|
||||||
)
|
)
|
||||||
@ -515,7 +503,6 @@ later is required to fix a server side protocol bug.
|
|||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
"--optimized-fetch",
|
"--optimized-fetch",
|
||||||
dest="optimized_fetch",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="only fetch projects fixed to sha1 if revision does not exist "
|
help="only fetch projects fixed to sha1 if revision does not exist "
|
||||||
"locally",
|
"locally",
|
||||||
@ -554,7 +541,6 @@ later is required to fix a server side protocol bug.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-s",
|
"-s",
|
||||||
"--smart-sync",
|
"--smart-sync",
|
||||||
dest="smart_sync",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="smart sync using manifest from the latest known good "
|
help="smart sync using manifest from the latest known good "
|
||||||
"build",
|
"build",
|
||||||
@ -562,7 +548,6 @@ later is required to fix a server side protocol bug.
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-t",
|
"-t",
|
||||||
"--smart-tag",
|
"--smart-tag",
|
||||||
dest="smart_tag",
|
|
||||||
action="store",
|
action="store",
|
||||||
help="smart sync using manifest from a known tag",
|
help="smart sync using manifest from a known tag",
|
||||||
)
|
)
|
||||||
@ -577,7 +562,6 @@ later is required to fix a server side protocol bug.
|
|||||||
)
|
)
|
||||||
g.add_option(
|
g.add_option(
|
||||||
"--repo-upgraded",
|
"--repo-upgraded",
|
||||||
dest="repo_upgraded",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help=optparse.SUPPRESS_HELP,
|
help=optparse.SUPPRESS_HELP,
|
||||||
)
|
)
|
||||||
|
@ -267,7 +267,6 @@ Gerrit Code Review: https://www.gerritcodereview.com/
|
|||||||
"--cc",
|
"--cc",
|
||||||
type="string",
|
type="string",
|
||||||
action="append",
|
action="append",
|
||||||
dest="cc",
|
|
||||||
help="also send email to these email addresses",
|
help="also send email to these email addresses",
|
||||||
)
|
)
|
||||||
p.add_option(
|
p.add_option(
|
||||||
@ -281,7 +280,6 @@ Gerrit Code Review: https://www.gerritcodereview.com/
|
|||||||
p.add_option(
|
p.add_option(
|
||||||
"-c",
|
"-c",
|
||||||
"--current-branch",
|
"--current-branch",
|
||||||
dest="current_branch",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="upload current git branch",
|
help="upload current git branch",
|
||||||
)
|
)
|
||||||
@ -310,7 +308,6 @@ Gerrit Code Review: https://www.gerritcodereview.com/
|
|||||||
"-p",
|
"-p",
|
||||||
"--private",
|
"--private",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
dest="private",
|
|
||||||
default=False,
|
default=False,
|
||||||
help="upload as a private change (deprecated; use --wip)",
|
help="upload as a private change (deprecated; use --wip)",
|
||||||
)
|
)
|
||||||
@ -318,7 +315,6 @@ Gerrit Code Review: https://www.gerritcodereview.com/
|
|||||||
"-w",
|
"-w",
|
||||||
"--wip",
|
"--wip",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
dest="wip",
|
|
||||||
default=False,
|
default=False,
|
||||||
help="upload as a work-in-progress change",
|
help="upload as a work-in-progress change",
|
||||||
)
|
)
|
||||||
|
@ -89,3 +89,44 @@ class AllCommands(unittest.TestCase):
|
|||||||
msg=f"subcmds/{name}.py: {opt}: only use dashes in "
|
msg=f"subcmds/{name}.py: {opt}: only use dashes in "
|
||||||
"options, not underscores",
|
"options, not underscores",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_cli_option_dest(self):
|
||||||
|
"""Block redundant dest= arguments."""
|
||||||
|
|
||||||
|
def _check_dest(opt):
|
||||||
|
if opt.dest is None or not opt._long_opts:
|
||||||
|
return
|
||||||
|
|
||||||
|
long = opt._long_opts[0]
|
||||||
|
assert long.startswith("--")
|
||||||
|
# This matches optparse's behavior.
|
||||||
|
implicit_dest = long[2:].replace("-", "_")
|
||||||
|
if implicit_dest == opt.dest:
|
||||||
|
bad_opts.append((str(opt), opt.dest))
|
||||||
|
|
||||||
|
# Hook the option check list.
|
||||||
|
optparse.Option.CHECK_METHODS.insert(0, _check_dest)
|
||||||
|
|
||||||
|
# Gather all the bad options up front so people can see all bad options
|
||||||
|
# instead of failing at the first one.
|
||||||
|
all_bad_opts = {}
|
||||||
|
for name, cls in subcmds.all_commands.items():
|
||||||
|
bad_opts = all_bad_opts[name] = []
|
||||||
|
cmd = cls()
|
||||||
|
# Trigger construction of parser.
|
||||||
|
cmd.OptionParser
|
||||||
|
|
||||||
|
errmsg = None
|
||||||
|
for name, bad_opts in sorted(all_bad_opts.items()):
|
||||||
|
if bad_opts:
|
||||||
|
if not errmsg:
|
||||||
|
errmsg = "Omit redundant dest= when defining options.\n"
|
||||||
|
errmsg += f"\nSubcommand {name} (subcmds/{name}.py):\n"
|
||||||
|
errmsg += "".join(
|
||||||
|
f" {opt}: dest='{dest}'\n" for opt, dest in bad_opts
|
||||||
|
)
|
||||||
|
if errmsg:
|
||||||
|
self.fail(errmsg)
|
||||||
|
|
||||||
|
# Make sure we aren't popping the wrong stuff.
|
||||||
|
assert optparse.Option.CHECK_METHODS.pop(0) is _check_dest
|
||||||
|
Reference in New Issue
Block a user