Skip to content

Commit

Permalink
Add ability to specify refresh delay
Browse files Browse the repository at this point in the history
Bump version to 1.0.1
  • Loading branch information
sakaki- committed Jan 21, 2015
1 parent 24016da commit 2d92e57
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
17 changes: 12 additions & 5 deletions showem
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set -u

# ********************** variables *********************
PROGNAME="$(basename "${0}")"
VERSION="1.0.0"
VERSION="1.0.1"
PORTAGE_BUILD_DIR="/var/tmp/portage"
MAIN_LOG_DIR="/var/log"
EMERGE_FETCH_LOG="emerge-fetch.log"
Expand All @@ -37,8 +37,9 @@ LOG_FILE_STALE_MINS=5
RED_TEXT="$(tput setaf 1)"
GREEN_TEXT="$(tput setaf 2)"
RESET_ATTS="$(tput sgr0)"

# program arguments (booleans in this case)
declare -i ARG_HELP=0 ARG_VERSION=0
declare -i ARG_HELP=0 ARG_VERSION=0 REFRESH_WAIT_SECS=1

# ***************** various functions ******************
cleanup_and_exit_with_code() {
Expand Down Expand Up @@ -104,6 +105,8 @@ Usage: ${PROGNAME} [options]
Options:
-h, --help show this help message and exit
-s, --wait-seconds=S specify number of seconds S to pause
between screen refreshes (default, 1)
-V, --version display the version number of ${PROGNAME} and exit
EOF
}
Expand All @@ -123,7 +126,7 @@ display_usage_message_and_bail_out() {
process_command_line_options() {
local TEMP
declare -i RC
TEMP="$(getopt -o hV --long help,version -n "${PROGNAME}" -- "${@}")"
TEMP="$(getopt -o hs:V --long help,wait-seconds:,version -n "${PROGNAME}" -- "${@}")"
RC="${?}"
if ((RC!=0)); then
display_usage_message_and_bail_out
Expand All @@ -134,6 +137,11 @@ process_command_line_options() {
while true ; do
case "${1}" in
-h|--help) ARG_HELP=1 ; shift ;;
-s|--wait-seconds)
case "${2}" in
"") REFRESH_WAIT_SECS=1 ; shift 2 ;;
*) REFRESH_WAIT_SECS="${2}" ; shift 2 ;;
esac ;;
-V|--version) ARG_VERSION=1 ; shift ;;
--) shift ; break ;;
*) die "Internal error!" ;;
Expand Down Expand Up @@ -206,8 +214,7 @@ main_monitor_loop() {
print_line_divider "=" "NONE"
# Set xterm title to show current build log relative path
echo -ne "\033]0;${PROGNAME}: ${CURRENT_LOG#${PORTAGE_BUILD_DIR}/}\007"

sleep 1
sleep ${REFRESH_WAIT_SECS}
done
}
# *************** start of script proper ***************
Expand Down
8 changes: 6 additions & 2 deletions showem.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH SHOWEM 1 "Version 1.0.0: July 2014"
.TH SHOWEM 1 "Version 1.0.1: January 2015"
.SH NAME
showem \- monitor the progress of a parallel \fBemerge\fR(1)
.SH SYNOPSIS
Expand All @@ -9,7 +9,7 @@ showem \- monitor the progress of a parallel \fBemerge\fR(1)
is a very simple utility script, which allows you to monitor the progress of
a parallel \fBemerge\fR(1).

When invoked, it shows a split screen display, which updates once a second.
When invoked, it shows a split screen display, which updates once a second (or as otherwise specified by the \fB--wait-seconds\fR option).
The top part shows the tail of the current \fBPortage\fR(5) download log,
and the lower part shows the tail of the most recent \fBPortage\fR(5)
build log.
Expand All @@ -28,6 +28,10 @@ Exit \fBshowem\fR using \fBCtrl-c\fR, when done.
.BR \-h ", " \-\-help
Displays a short help screen, and exits.
.TP
.BR \-s ", " \-\-wait\-seconds\=S
Specifies the number of seconds, S, to pause between screen refreshes.
The default is 1.
.TP
.BR \-V ", " \-\-version
Displays the version number of \fBshowem\fR, and exits.
.SH COMPATIBILITY
Expand Down

0 comments on commit 2d92e57

Please sign in to comment.