2 Commits
v2.2 ... v2.4

Author SHA1 Message Date
fbt
7d778ecd66 Better argument handling. 2015-01-31 18:45:47 +03:00
fbt
aa8929ff8e a fix for multiple dependencies. 2015-01-29 12:35:07 +03:00

59
zpac
View File

@@ -18,10 +18,10 @@ usage() {
Flags:
-h Show this message.
-s Search for <package>.
-S Search only in the sync db. Implies -s.
-A Search only in AUR. Implies -s.
-S Search only in the sync db. Implies -s.
-A Search only in AUR. Implies -s.
-d Get the package sources (default).
-D Get the dependencies also. Implies -d.
Set twice to also get the dependencies.
EOF
}
@@ -86,7 +86,7 @@ aur.get() {
aur_deps_count=$( jshon -e resultcount <<< "$aur_deps_api_data" )
if (( aur_deps_count )); then
aur_deps=$( jshon -e results -a -e Name -u <<< "$aur_deps_api_data" )
aur_deps=( $( jshon -e results -a -e Name -u <<< "$aur_deps_api_data" ) )
for i in "${aur_deps[@]}"; do
aur.get < <(aur.info "$i") || {
@@ -112,6 +112,44 @@ abs.get() {
svn checkout "svn://svn.archlinux.org/${svn_repo}/${1}/trunk" "${cfg_workdir}/${1}"
}
args_norm() {
while (( $# )); do
unset -v arg opt c keys
case "$1" in
--) shift; break;;
--*)
IFS='=' read arg opt <<< "$1"
printf '%s\n' "$arg"
[[ "$opt" ]] && {
printf '%s\n' "$opt"
}
;;
-*)
while read -n1 c
do
case "$c" in
-|'') :;;
*) keys+=( "-$c" );;
esac
done <<< "$1"
printf '%s\n' "${keys[@]}"
;;
esac
[[ "$2" && ! "$2" =~ ^- ]] && {
printf '%s\n' "$2"
shift
}
shift
done
}
main() {
if [[ -f "$HOME/.config/zpac.rc.sh" ]]; then
source "$HOME/.config/zpac.rc.sh"
@@ -129,10 +167,13 @@ main() {
action='search'
flag_search_syncdb=1;;
(-d) action='get';;
(-D)
action='get'
flag_get_deps=1;;
(-d)
if [[ "$action" == 'get' ]]; then
flag_get_deps=1
else
action='get'
fi
;;
(--) shift; break;;
(-*)
@@ -224,4 +265,4 @@ main() {
esac
}
main "$@"
main $(args_norm "$@")