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

epm-play: improve options parsing

parent 9cd80fc9
......@@ -40,25 +40,30 @@ __remove_installed_app()
return 0
}
__check_installed_app()
__run_script()
{
local script="$psdir/$1.sh"
[ -x "$script" ] || return
$script --installed
shift
$script "$@"
return
}
[ -s $epm_vardir/installed-app ] || return 1
grep -q -- "^$1\$" $epm_vardir/installed-app
__get_app_package()
{
__run_script "$1" --package-name "$2" 2>/dev/null
}
__get_app_version()
__check_installed_app()
{
local script="$psdir/$1.sh"
[ -x "$script" ] || return
$script --installed-version
__run_script "$1" --installed "$2"
return
[ -s $epm_vardir/installed-app ] || return 1
grep -q -- "^$1\$" $epm_vardir/installed-app
}
__list_all_app()
{
for i in $psdir/*.sh ; do
......@@ -101,19 +106,10 @@ __list_installed_app()
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()
{
local script="$psdir/$1.sh"
[ -x "$script" ] || return
$script --description 2>/dev/null
__run_script "$1" --description 2>/dev/null
}
__check_play_script()
......@@ -262,23 +258,23 @@ fi
if [ "$1" = "--installed" ] || [ "$1" = "installed" ] ; then
shift
__check_installed_app "$1"
__check_installed_app "$1" "$2"
#[ -n "$quiet" ] && exit
exit
fi
if [ "$1" = "--installed-version" ] || [ "$1" = "installed-version" ] ; then
shift
__get_app_version "$1"
#[ -n "$quiet" ] && exit
# common internal options
case "$1" in
"--installed-version"|"--package-name"|"--product-alternatives")
__run_script "$2" "$1" "$3"
exit
fi
if [ "$1" = "--package-name" ] || [ "$1" = "package-name" ] ; then
shift
__get_app_package "$1"
;;
"--help"|"help")
__run_script "$2" "$1" "$3"
exit
fi
;;
esac
if [ "$1" = "--list" ] || [ "$1" = "--list-installed" ] || [ "$1" = "list" ] || [ "$1" = "list-installed" ] ; then
__epm_play_list_installed
......
......@@ -32,7 +32,7 @@ case "$1" in
[ -n "$TIPS" ] && echo "$TIPS"
exit
;;
"--package")
"--package-name")
echo "$PKGNAME"
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