mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 02:31:29 +00:00
Add git completion helper to cl upload
This is similar in spirit to the helper flags in git subcommands, e.g. try `git branch --git-completion-helper`. It provides a list of long flags that the subcommands support, without repeating it manually in the completion script. Note that this special flag is not returned in help, so there is no noise. To see the result, source the script, then `git cl upload --<TAB>`. Change-Id: I82e280ceac5178b0e5fa52611b9a4125e6943337 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2209926 Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org> Commit-Queue: Zhi An Ng <zhin@chromium.org>
This commit is contained in:
@@ -4048,10 +4048,17 @@ def CMDupload(parser, args):
|
|||||||
help='Modify description before upload. Cannot be used '
|
help='Modify description before upload. Cannot be used '
|
||||||
'with --force. It is a noop when --no-squash is set '
|
'with --force. It is a noop when --no-squash is set '
|
||||||
'or a new commit is created.')
|
'or a new commit is created.')
|
||||||
|
parser.add_option('--git-completion-helper', action="store_true",
|
||||||
|
help=optparse.SUPPRESS_HELP)
|
||||||
|
|
||||||
orig_args = args
|
orig_args = args
|
||||||
(options, args) = parser.parse_args(args)
|
(options, args) = parser.parse_args(args)
|
||||||
|
|
||||||
|
if options.git_completion_helper:
|
||||||
|
print(' '.join(opt.get_opt_string() for opt in parser.option_list
|
||||||
|
if opt.help != optparse.SUPPRESS_HELP))
|
||||||
|
return
|
||||||
|
|
||||||
if git_common.is_dirty_git_tree('upload'):
|
if git_common.is_dirty_git_tree('upload'):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|||||||
@@ -30,5 +30,19 @@ __git_cl_compute_all_commands () {
|
|||||||
|
|
||||||
_git_cl () {
|
_git_cl () {
|
||||||
__git_cl_compute_all_commands
|
__git_cl_compute_all_commands
|
||||||
__gitcomp_nl "${__git_cl_all_commands}"
|
local subcommands=$(echo "$__git_cl_all_commands" | xargs)
|
||||||
|
local subcommand=$(__git_find_on_cmdline "$subcommands")
|
||||||
|
if [[ -z "$subcommand" ]]; then
|
||||||
|
__gitcomp "$subcommands"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$subcommand,$cur" in
|
||||||
|
upload,--*)
|
||||||
|
__gitcomp_builtin cl_upload
|
||||||
|
;;
|
||||||
|
"",*)
|
||||||
|
__gitcomp_nl "${__git_cl_all_commands}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user