blob: 48d83615854a2089a70146e1cee91f2a53c6adbc [file]
#compdef jiri
_jiri() {
local -a commands
commands=(
'branch:Show or delete branches'
'clean:Clean Jiri workspace (main tree or worktree)'
'diff:Prints diff between two snapshots'
'flags:describe all known top-level flags'
'grep:Search across projects'
'help:describe subcommands and their syntax'
'init:Create a new jiri root'
'patch:Patch in the existing change'
'project:Manage the jiri projects'
'runp:Run a command in parallel across jiri projects'
'selfupdate:Update jiri tool'
'snapshot:Create a new project snapshot'
'status:Prints status of all the projects'
'update:Update all jiri projects'
'upload:Upload a changelist for review'
'version:Print the jiri version'
'worktree:Manage Jiri worktrees'
)
_arguments \
'(-v -vv -q -quiet)'{-v,-vv}'[Print debug/trace level output]' \
'(-v -vv -q -quiet)'{-q,-quiet}'[Only print user actionable messages]' \
'-color[Use color]:color:(always never auto)' \
'-j[Number of jobs]:jobs' \
'-root[Jiri root directory]:directory:_files -/' \
'1: :{_describe "Jiri command" commands}' \
'*:: :->args'
if [[ $state == "args" ]]; then
case $words[1] in
branch)
_jiri_branch
;;
clean)
_jiri_clean
;;
diff)
_jiri_diff
;;
grep)
_jiri_grep
;;
init)
_jiri_init
;;
patch)
_jiri_patch
;;
project)
_jiri_project
;;
runp)
_jiri_runp
;;
snapshot)
_jiri_snapshot
;;
status)
_jiri_status
;;
update)
_jiri_update
;;
upload)
_jiri_upload
;;
worktree)
_jiri_worktree
;;
*)
_normal
;;
esac
fi
}
_jiri_worktree() {
local -a subcommands
subcommands=(
'add:Create a new Jiri worktree'
'list:List Jiri worktrees'
'remove:Remove a Jiri worktree'
'sync:Sync Jiri worktree'
'prune:Prune Jiri worktrees'
)
_arguments \
'1: :{_describe "worktree subcommand" subcommands}' \
'*:: :->args'
if [[ $state == "args" ]]; then
case $words[1] in
add)
_arguments \
'1:directory:_files -/'
;;
remove)
_arguments \
'(-f -force)'{-f,-force}'[Force removal even if dirty]' \
'1:worktree:_jiri_worktrees'
;;
sync)
_arguments \
'1:directory:_files -/'
;;
list)
_arguments \
'-status[Show sync status for each worktree]'
;;
esac
fi
}
_jiri_worktrees() {
local -a wts
wts=( ${(f)"$(jiri worktree list 2>/dev/null)"} )
_describe 'worktree' wts
}
_jiri_branches() {
local -a branches
branches=( ${(f)"$(jiri branch 2>/dev/null | grep 'Branch(es):' | cut -d: -f2 | tr ',' '\n' | tr -d ' ' | sort -u)"} )
_describe 'branch' branches
}
_jiri_projects() {
local -a projects
projects=( ${(f)"$(jiri project -template '{{.Name}}' 2>/dev/null)"} )
_describe 'project' projects
}
_jiri_branch() {
_arguments \
'-D[Force delete branch from project]' \
'-d[Delete branch from project]' \
'-delete-merged[Delete merged branches]' \
'-delete-merged-cl[Delete merged branches and check Gerrit]' \
'-override-pc[Override project config]' \
'1:branch name:_jiri_branches'
}
_jiri_clean() {
_arguments \
'1:directory:_files -/'
}
_jiri_diff() {
_arguments \
'-cls[Return CLs for changed projects]' \
'-indent[Indent json output]' \
'-max-cls[Max number of CLs returned per changed project]:number' \
'1:snapshot 1:_files' \
'2:snapshot 2:_files'
}
_jiri_grep() {
_arguments \
'-H[Does nothing]' \
'-L[Show only names of files that do not contain matches]' \
'-cwd-rel[Output paths relative to CWD]' \
'-e[Pattern starts with -]:pattern' \
'-files-with-matches[Show only names of files that contain matches]' \
'-files-without-match[Show only names of files that do not contain matches]' \
'-i[Ignore case]' \
'-l[Show only names of files that contain matches]' \
'-n[Prefix line number]' \
'-name-only[Show only names of files that contain matches]' \
'-w[Match word boundary]' \
'1:query:' \
'*:pathspec:_files'
}
_jiri_init() {
_arguments \
'-analytics-opt[Opt in/out of analytics]:enable:(true false)' \
'-cache[Jiri cache directory]:directory:_files -/' \
'-cipd-max-threads[Number of threads for CIPD]:threads' \
'-cipd-paranoid-mode[Paranoid mode in cipd]:mode' \
'-dissociate[Dissociate git cache]' \
'-enable-lockfile[Enable lockfile enforcement]:enable:(true false)' \
'-exclude-dirs[Directories to skip]:directories' \
'-fetch-optional[Set up optional projects/packages to fetch]:attributes' \
'-keep-git-hooks[Keep current git hooks]:enable:(true false)' \
'-lockfile-name[Lockfile filename]:filename:_files' \
'-offload-packfiles[Use CDN for packfiles]' \
'-package-cache[Enable package cache]:enable:(true false)' \
'-partial[Use partial checkout]' \
'-prebuilt-json[Prebuilt json file]:filename:_files' \
'-rewrite-sso-to-https[Rewrite SSO to HTTPS]:enable:(true false)' \
'-shared[Shared caches]' \
'-show-analytics-data[Show analytics data]' \
'-skip-partial[Skip partial checkouts for remotes]:remotes' \
'-sso-cookie-path[Path to master SSO cookie]:file:_files' \
'1:directory:_files -/'
}
_jiri_patch() {
_arguments \
'-branch[Name of branch to apply patch to]:branch' \
'-cherry-pick[Cherry-pick patches]' \
'-delete[Delete existing branch]' \
'-force[Force delete existing branch]' \
'-host[Gerrit host]:host' \
'-no-branch[Do not create branch]' \
'-project[Project to apply patch to]:project:_jiri_projects' \
'-rebase[Rebase change after downloading]' \
'-rebase-branch[Branch to rebase onto]:branch' \
'-rebase-revision[Revision to rebase to]:revision' \
'-topic[Patch whole topic]' \
'1:change or topic:'
}
_jiri_project() {
_arguments \
'-clean[Restore projects to pristine state]' \
'-clean-all[Restore projects and delete all branches]' \
'-json-output[Path to write results]:file:_files' \
'-list-remote-projects[List remote projects]' \
'-local-manifest[List status based on local manifest]' \
'*-local-manifest-project[Respect local manifest for project]:project:_jiri_projects' \
'-regexp[Use argument as regexp]' \
'-template[Template for fields]:template' \
'*:project:_jiri_projects'
}
_jiri_runp() {
_arguments \
'-branch[Branch names to match projects]:branch' \
'-collate-stdout[Collate stdout output]' \
'-exit-on-error[Kill all commands on error]' \
'-interactive[Interactive command]' \
'-no-uncommitted[Match projects with no uncommitted changes]' \
'-no-untracked[Match projects with no untracked files]' \
'-projects[Project keys to run commands in]:projects' \
'-remote[Match projects by remote URL]:remote' \
'-show-key-prefix[Prefix output with project key]' \
'-show-name-prefix[Prefix output with project name]' \
'-show-path-prefix[Prefix output with project path]' \
'-uncommitted[Match projects with uncommitted changes]' \
'-untracked[Match projects with untracked files]' \
'1:command line:'
}
_jiri_snapshot() {
_arguments \
'-cipd[Generate cipd.ensure snapshot]' \
'1:snapshot file:_files'
}
_jiri_status() {
_arguments \
'-branch[Display projects on this branch]:branch' \
'-changes[Display projects with changes]' \
'-check-head[Display projects not on HEAD]' \
'-commits[Display commits not merged with remote]' \
'-d[Same as -deleted]' \
'-deleted[List deleted projects]'
}
_jiri_update() {
_arguments \
'-attempts[Number of attempts]:attempts' \
'-autoupdate[Automatically update jiri]' \
'-fetch-packages[Use cipd to fetch packages]' \
'-fetch-packages-timeout[Timeout for cipd fetch]:timeout (minutes)' \
'-force-autoupdate[Always update jiri]' \
'-gc[Garbage collect obsolete repos]' \
'-hook-timeout[Timeout for hooks]:timeout (minutes)' \
'-local-manifest[Use local manifest]' \
'*-local-manifest-project[Respect local manifest for project]:project:_jiri_projects' \
'-override-optional[Override existing optional attributes]' \
'*-package-to-skip[Skip fetching package]:package' \
'-rebase-all[Rebase all tracked branches]' \
'-rebase-current[Deprecated. Implies -rebase-tracked]' \
'-rebase-tracked[Rebase current tracked branches]' \
'-rebase-untracked[Rebase untracked branches onto HEAD]' \
'-run-hooks[Run hooks after update]' \
'1:snapshot file or url:_files'
}
_jiri_upload() {
_arguments \
'-branch[Multipart branch]:branch' \
'-cc[CC emails/LDAPs]:cc' \
'-git-options[Passthrough git options]:options' \
'-l[Review labels]:labels' \
'-multipart[Send multipart CL]' \
'-presubmit[Presubmit type]:type:(none all)' \
'-r[Reviewer emails/LDAPs]:reviewers' \
'-rebase[Rebase before pushing]' \
'-remoteBranch[Remote branch]:branch' \
'-set-topic[Set topic]' \
'-topic[CL topic]:topic' \
'-verify[Run pre-push git hooks]' \
'1:ref:'
}
_jiri