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]..." ...@@ -56,6 +56,7 @@ Usage="Usage: epm [options] <command> [package name(s), package files]..."
Descr="epm - EPM package manager" Descr="epm - EPM package manager"
verbose= verbose=
quiet=
non_interactive= non_interactive=
epm_cmd= epm_cmd=
pkg_files= pkg_files=
...@@ -93,6 +94,9 @@ for opt in "$@" ; do ...@@ -93,6 +94,9 @@ for opt in "$@" ; do
--verbose) # HELPOPT: verbose mode --verbose) # HELPOPT: verbose mode
verbose=1 verbose=1
;; ;;
--quiet) # HELPOPT: quiet mode (do not print commands before exec)
quiet=1
;;
--auto) # HELPOPT: non interactive mode --auto) # HELPOPT: non interactive mode
non_interactive=1 non_interactive=1
;; ;;
......
...@@ -18,6 +18,35 @@ ...@@ -18,6 +18,35 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. # 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() echover()
{ {
[ -n "$verbose" ] || return [ -n "$verbose" ] || return
...@@ -42,11 +71,13 @@ realpath() ...@@ -42,11 +71,13 @@ realpath()
# Print command line and run command line # Print command line and run command line
docmd() docmd()
{ {
#SETCOLOR_SUCCESS if [ -z "$quiet" ] ; then
local PROMTSIG="\$" set_boldcolor $GREEN
[ "$UID" = 0 ] && PROMTSIG="#" local PROMTSIG="\$"
echo " $PROMTSIG $@" [ "$UID" = 0 ] && PROMTSIG="#"
#SETCOLOR_NORMAL echo " $PROMTSIG $@"
restore_color
fi
"$@" "$@"
} }
...@@ -125,3 +156,4 @@ case $DISTRNAME in ...@@ -125,3 +156,4 @@ case $DISTRNAME in
esac esac
PMTYPE=$CMD 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