-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from jflorian/develop
bash-completion for tito command
- Loading branch information
Showing
2 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# Copyright (c) 2015 John Florian <jflorian@doubledog.org> | ||
# | ||
# This software is licensed to you under the GNU General Public License, | ||
# version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
# implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
# along with this software; if not, see | ||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
|
||
|
||
__tito_modules='build init release report tag' | ||
|
||
# Excluding short options here because they'd save no keystrokes and only make | ||
# these longer, more intuitive options less accessible. | ||
__tito_opts='--help' | ||
|
||
__tito_build_opts=' | ||
--arg= | ||
--builder= | ||
--debug | ||
--dist= | ||
--help | ||
--install | ||
--list-tags | ||
--no-cleanup | ||
--only-tags= | ||
--output= | ||
--rpm | ||
--rpmbuild-options= | ||
--scl= | ||
--srpm | ||
--tag= | ||
--test | ||
--tgz | ||
' | ||
|
||
__tito_release_opts=' | ||
--all | ||
--all-starting-with= | ||
--debug | ||
--dry-run | ||
--help | ||
--list | ||
--no-build | ||
--no-cleanup | ||
--output= | ||
--scratch | ||
--tag= | ||
--test | ||
--yes | ||
' | ||
|
||
__tito_report_opts=' | ||
--debug | ||
--help | ||
--output= | ||
--untagged-diffs | ||
--untagged-commits | ||
' | ||
|
||
__tito_tag_opts=' | ||
--accept-auto-changelog | ||
--auto-changelog-message= | ||
--debug | ||
--help | ||
--keep-version | ||
--no-auto-changelog | ||
--output= | ||
--undo | ||
--use-version= | ||
' | ||
|
||
_tito_get_release_targets() { | ||
# Ideally tito would return an exit code of 0 upon success, but it seems | ||
# to return 1 whether run within a git checkout or not. Hence this | ||
# kludge: | ||
if tito release --list 2> /dev/null | grep -q 'Available release targets' | ||
then | ||
tito release --list | tail -n +2 | ||
fi | ||
} | ||
|
||
_tito() { | ||
local cur opts module | ||
|
||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
module="${COMP_WORDS[1]}" | ||
|
||
opts="${__tito_modules} ${__tito_opts}" | ||
|
||
case "${module}" in | ||
|
||
build) | ||
COMPREPLY=( $(compgen -W "${__tito_build_opts}" -- ${cur}) ) | ||
return 0 | ||
;; | ||
|
||
release) | ||
COMPREPLY=( $(compgen -W \ | ||
"${__tito_release_opts} $(_tito_get_release_targets)" \ | ||
-- ${cur}) \ | ||
) | ||
return 0 | ||
;; | ||
|
||
report) | ||
COMPREPLY=( $(compgen -W "${__tito_report_opts}" -- ${cur}) ) | ||
return 0 | ||
;; | ||
|
||
tag) | ||
COMPREPLY=( $(compgen -W "${__tito_tag_opts}" -- ${cur}) ) | ||
return 0 | ||
;; | ||
|
||
esac | ||
|
||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | ||
return 0 | ||
} | ||
|
||
complete -F _tito tito |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters