Commit ad1ac3a9 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm: add quiet mode (no print commands before run), add color support for output

parent a9c283b7
......@@ -56,6 +56,7 @@ Usage="Usage: epm [options] <command> [package name(s), package files]..."
Descr="epm - EPM package manager"
verbose=
quiet=
non_interactive=
epm_cmd=
pkg_files=
......@@ -93,6 +94,9 @@ for opt in "$@" ; do
--verbose) # HELPOPT: verbose mode
verbose=1
;;
--quiet) # HELPOPT: quiet mode (do not print commands before exec)
quiet=1
;;
--auto) # HELPOPT: non interactive mode
non_interactive=1
;;
......
......@@ -18,6 +18,35 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
# copied from /etc/init.d/outformat (ALT Linux)
isatty()
{
# Set a sane TERM required for tput
[ -n "$TERM" ] || TERM=dumb
export TERM
test -t 1
}
: ${BLACK:=0} ${RED:=1} ${GREEN:=2} ${YELLOW:=3} ${BLUE:=4} ${MAGENTA:=5} ${CYAN:=6} ${WHITE:=7}
set_boldcolor()
{
isatty || return
{
echo bold
echo setaf $1
} |tput -S
}
restore_color()
{
isatty || return
{
echo op; # set Original color Pair.
echo sgr0; # turn off all special graphics mode (bold in our case).
} |tput -S
}
echover()
{
[ -n "$verbose" ] || return
......@@ -42,11 +71,13 @@ realpath()
# Print command line and run command line
docmd()
{
#SETCOLOR_SUCCESS
local PROMTSIG="\$"
[ "$UID" = 0 ] && PROMTSIG="#"
echo " $PROMTSIG $@"
#SETCOLOR_NORMAL
if [ -z "$quiet" ] ; then
set_boldcolor $GREEN
local PROMTSIG="\$"
[ "$UID" = 0 ] && PROMTSIG="#"
echo " $PROMTSIG $@"
restore_color
fi
"$@"
}
......@@ -125,3 +156,4 @@ case $DISTRNAME in
esac
PMTYPE=$CMD
}
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