Commit 3de98e80 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm-play: improve options parsing

parent 9cd80fc9
...@@ -40,25 +40,30 @@ __remove_installed_app() ...@@ -40,25 +40,30 @@ __remove_installed_app()
return 0 return 0
} }
__check_installed_app() __run_script()
{ {
local script="$psdir/$1.sh" local script="$psdir/$1.sh"
[ -x "$script" ] || return [ -x "$script" ] || return
$script --installed shift
$script "$@"
return return
}
[ -s $epm_vardir/installed-app ] || return 1 __get_app_package()
grep -q -- "^$1\$" $epm_vardir/installed-app {
__run_script "$1" --package-name "$2" 2>/dev/null
} }
__get_app_version() __check_installed_app()
{ {
local script="$psdir/$1.sh" __run_script "$1" --installed "$2"
[ -x "$script" ] || return
$script --installed-version
return return
[ -s $epm_vardir/installed-app ] || return 1
grep -q -- "^$1\$" $epm_vardir/installed-app
} }
__list_all_app() __list_all_app()
{ {
for i in $psdir/*.sh ; do for i in $psdir/*.sh ; do
...@@ -101,19 +106,10 @@ __list_installed_app() ...@@ -101,19 +106,10 @@ __list_installed_app()
cat $epm_vardir/installed-app 2>/dev/null cat $epm_vardir/installed-app 2>/dev/null
} }
__get_app_package()
{
local script="$psdir/$1.sh"
[ -x "$script" ] || return
$script --package 2>/dev/null
}
__get_app_description() __get_app_description()
{ {
local script="$psdir/$1.sh" __run_script "$1" --description 2>/dev/null
[ -x "$script" ] || return
$script --description 2>/dev/null
} }
__check_play_script() __check_play_script()
...@@ -262,23 +258,23 @@ fi ...@@ -262,23 +258,23 @@ fi
if [ "$1" = "--installed" ] || [ "$1" = "installed" ] ; then if [ "$1" = "--installed" ] || [ "$1" = "installed" ] ; then
shift shift
__check_installed_app "$1" __check_installed_app "$1" "$2"
#[ -n "$quiet" ] && exit #[ -n "$quiet" ] && exit
exit exit
fi fi
if [ "$1" = "--installed-version" ] || [ "$1" = "installed-version" ] ; then # common internal options
shift case "$1" in
__get_app_version "$1" "--installed-version"|"--package-name"|"--product-alternatives")
#[ -n "$quiet" ] && exit __run_script "$2" "$1" "$3"
exit exit
fi ;;
"--help"|"help")
__run_script "$2" "$1" "$3"
exit
;;
esac
if [ "$1" = "--package-name" ] || [ "$1" = "package-name" ] ; then
shift
__get_app_package "$1"
exit
fi
if [ "$1" = "--list" ] || [ "$1" = "--list-installed" ] || [ "$1" = "list" ] || [ "$1" = "list-installed" ] ; then if [ "$1" = "--list" ] || [ "$1" = "--list-installed" ] || [ "$1" = "list" ] || [ "$1" = "list-installed" ] ; then
__epm_play_list_installed __epm_play_list_installed
......
...@@ -32,7 +32,7 @@ case "$1" in ...@@ -32,7 +32,7 @@ case "$1" in
[ -n "$TIPS" ] && echo "$TIPS" [ -n "$TIPS" ] && echo "$TIPS"
exit exit
;; ;;
"--package") "--package-name")
echo "$PKGNAME" echo "$PKGNAME"
exit exit
;; ;;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment