Skip to content

Commit

Permalink
Complete carthage arguments
Browse files Browse the repository at this point in the history
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
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 2 deletions.
3 changes: 2 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ History of Yash
Yash 2.42

+ '--pipefail' option.
+ New completion script for: dnf, git-rev-parse, tree, watch
+ New completion script for: carthage, dnf, git-rev-parse, tree,
watch
+ Updated completion script for: cd, git, git-bisect, git-rev-list
(Git 2.9.2).
= Yash now supports the 2013 edition of POSIX.1-2008.
Expand Down
2 changes: 1 addition & 1 deletion NEWS.ja
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Yash 更新履歴
Yash 2.42

+ '--pipefail' オプション
+ 補完スクリプトを追加: dnf, git-rev-parse, tree, watch
+ 補完スクリプトを追加: carthage, dnf, git-rev-parse, tree, watch
+ 補完スクリプトを更新: cd, git, git-bisect, git-rev-list
(Git 2.9.2).
= POSIX.1-2008 の 2013 年版に準拠
Expand Down
222 changes: 222 additions & 0 deletions share/completion/carthage
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:

0 comments on commit 7f89511

Please sign in to comment.