-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/yash/yash/trunk@3660 048f04df-13f5-43d7-8114-9f9ceecaec24
- Loading branch information
magicant
committed
Aug 26, 2016
1 parent
089a8a1
commit 7f89511
Showing
3 changed files
with
225 additions
and
2 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
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
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,222 @@ | ||
# (C) 2016 magicant | ||
|
||
# Completion script for the "carthage" command. | ||
# Supports Carthage 0.17.2. | ||
|
||
function completion/carthage { | ||
|
||
typeset OPTIONS ARGOPT PREFIX | ||
OPTIONS=() | ||
|
||
case ${WORDS[#]} in | ||
(1) | ||
command -f completion/carthage::completesubcmds | ||
;; | ||
(*) | ||
typeset subcmd="${WORDS[2]}" | ||
if command -vf "completion/carthage::$subcmd:arg" >/dev/null 2>&1; then | ||
WORDS=("${WORDS[2,-1]}") | ||
command -f "completion/carthage::$subcmd:arg" | ||
fi | ||
;; | ||
esac | ||
|
||
} | ||
|
||
function completion/carthage::getbuildoptions { | ||
OPTIONS=("$OPTIONS" #># | ||
"--configuration:" | ||
"--derived-data:" | ||
"--platform:" | ||
"--toolchain:" | ||
"--verbose" | ||
) #<# | ||
} | ||
|
||
function completion/carthage::getcheckoutoptions { | ||
OPTIONS=("$OPTIONS" #># | ||
"--no-use-binaries" | ||
"--use-ssh" | ||
"--use-submodules" | ||
) #<# | ||
} | ||
|
||
function completion/carthage::getcpoptions { | ||
OPTIONS=("$OPTIONS" #># | ||
"--color:" | ||
"--project-directory:" | ||
) #<# | ||
} | ||
|
||
function completion/carthage::completeoptarg | ||
case $ARGOPT in | ||
(-) | ||
command -f completion//completeoptions -e | ||
;; | ||
(--derived-data|--project-directory) | ||
complete -P "$PREFIX" -S / -T -d | ||
;; | ||
(--color) | ||
complete -P "$PREFIX" always auto never | ||
;; | ||
(--configuration) | ||
# TODO Complete configuration | ||
;; | ||
(--platform) | ||
typeset word="${TARGETWORD#"$PREFIX"}" | ||
word=${word##*,} | ||
PREFIX=${TARGETWORD%"$word"} | ||
complete -P "$PREFIX" all Mac iOS watchOS tvOS | ||
;; | ||
(--toolchain) | ||
# TODO Complete toolchain | ||
;; | ||
esac | ||
|
||
function completion/carthage::completesubcmds { #>># | ||
complete -P "${PREFIX-}" archive bootstrap build checkout fetch help \ | ||
outdated update version | ||
} #<<# | ||
|
||
function completion/carthage::completedependencies { | ||
# This code can only complete dependencies that have already been | ||
# checked out in Carthage/Checkouts. Maybe we could improve candidates | ||
# by parsing Cartfile. | ||
typeset IFS=/ | ||
complete -P "$PREFIX" -- $( | ||
set -o glob -o nullglob | ||
cd -P "./$(git rev-parse --show-cdup)Carthage/Checkouts" \ | ||
2>/dev/null || exit | ||
candidates=(*/) | ||
candidates=("${candidates%/}") | ||
printf %s "${candidates[*]}" | ||
) | ||
} | ||
|
||
function completion/carthage::archive:arg { | ||
|
||
OPTIONS=( #># | ||
"--output:" | ||
) #<# | ||
command -f completion/carthage::getcpoptions | ||
|
||
command -f completion//parseoptions -e | ||
case $ARGOPT in | ||
('') | ||
# TODO complete framework | ||
;; | ||
(--output) | ||
complete -P "$PREFIX" -f | ||
;; | ||
(*) | ||
command -f completion/carthage::completeoptarg | ||
;; | ||
esac | ||
|
||
} | ||
|
||
function completion/carthage::bootstrap:arg { | ||
|
||
OPTIONS=( #># | ||
"--no-build" | ||
"--no-checkout" | ||
) #<# | ||
command -f completion/carthage::getbuildoptions | ||
command -f completion/carthage::getcheckoutoptions | ||
command -f completion/carthage::getcpoptions | ||
|
||
command -f completion//parseoptions -e | ||
case $ARGOPT in | ||
('') | ||
command -f completion/carthage::completedependencies | ||
;; | ||
(*) | ||
command -f completion/carthage::completeoptarg | ||
;; | ||
esac | ||
|
||
} | ||
|
||
function completion/carthage::build:arg { | ||
|
||
OPTIONS=( #># | ||
"--no-skip-current; build current project as well" | ||
) #<# | ||
command -f completion/carthage::getbuildoptions | ||
command -f completion/carthage::getcpoptions | ||
|
||
command -f completion//parseoptions -e | ||
case $ARGOPT in | ||
('') | ||
command -f completion/carthage::completedependencies | ||
;; | ||
(*) | ||
command -f completion/carthage::completeoptarg | ||
;; | ||
esac | ||
|
||
} | ||
|
||
function completion/carthage::checkout:arg { | ||
|
||
OPTIONS=() | ||
command -f completion/carthage::getcheckoutoptions | ||
command -f completion/carthage::getcpoptions | ||
|
||
command -f completion//parseoptions -e | ||
case $ARGOPT in | ||
('') | ||
command -f completion/carthage::completedependencies | ||
;; | ||
(*) | ||
command -f completion/carthage::completeoptarg | ||
;; | ||
esac | ||
|
||
} | ||
|
||
function completion/carthage::fetch:arg { | ||
|
||
OPTIONS=( #># | ||
"--color:" | ||
) #<# | ||
|
||
command -f completion//parseoptions -e | ||
case $ARGOPT in | ||
('') | ||
# TODO complete repository | ||
;; | ||
(*) | ||
command -f completion/carthage::completeoptarg | ||
;; | ||
esac | ||
|
||
} | ||
|
||
function completion/carthage::help:arg { | ||
command -f completion/carthage::completesubcmds | ||
} | ||
|
||
function completion/carthage::outdated:arg { | ||
|
||
OPTIONS=( #># | ||
"--use-ssh" | ||
"--verbose" | ||
) #<# | ||
command -f completion/carthage::getcpoptions | ||
|
||
command -f completion//parseoptions -e | ||
case $ARGOPT in | ||
(*) | ||
command -f completion/carthage::completeoptarg | ||
;; | ||
esac | ||
|
||
} | ||
|
||
function completion/carthage::update:arg { | ||
command -f completion/carthage::build:arg "$@" | ||
} | ||
|
||
|
||
# vim: set ft=sh ts=8 sts=8 sw=8 noet: |