Skip to content

Commit

Permalink
Merge pull request #176 from jflorian/develop
Browse files Browse the repository at this point in the history
bash-completion for tito command
  • Loading branch information
dgoodwin committed May 14, 2015
2 parents dcbbb7f + a4f6c52 commit 245696d
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
123 changes: 123 additions & 0 deletions share/tito_completion.sh
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
3 changes: 3 additions & 0 deletions tito.spec
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ rm -f $RPM_BUILD_ROOT%{python_sitelib}/*egg-info/requires.txt
%{__mkdir_p} %{buildroot}%{_mandir}/man8
cp -a titorc.5 tito.props.5 releasers.conf.5 %{buildroot}/%{_mandir}/man5/
cp -a tito.8 %{buildroot}/%{_mandir}/man8/
# bash completion facilities
install -Dp -m 0644 share/tito_completion.sh %{buildroot}%{_datadir}/bash-completion/completions/tito

%clean
rm -rf $RPM_BUILD_ROOT
Expand All @@ -113,6 +115,7 @@ rm -rf $RPM_BUILD_ROOT
%{_bindir}/tar-fixup-stamp-comment.pl
%{_bindir}/test-setup-specfile.pl
%{_bindir}/generate-patches.pl
%{_datadir}/bash-completion/completions/tito
%dir %{python_sitelib}/tito
%{python_sitelib}/tito/*
%{python_sitelib}/tito-*.egg-info
Expand Down

0 comments on commit 245696d

Please sign in to comment.