Skip to content

Commit

Permalink
add doclear support
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Davis <dug@us.ibm.com>
  • Loading branch information
Doug Davis committed Feb 5, 2020
1 parent 271b515 commit 3d4ae27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions demoscript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Set this environment variable to influence things...
Which means it might not work properly if the a command requires a previous
command to change something in the system - that change will not be there.
- `RETRYONFAIL` : Retry all `doit` commands that have unexcepted exit code.
- `DOCLEAR` : Clear the screen after each `doit` so that the next step will
be shown at the top of the screen. Good for demos.

## Demoing

Expand Down Expand Up @@ -77,6 +79,7 @@ Options:
- `--pausetime=xx` : when using `--untilgrep` you can exit the loop by pressing
any key. This waits `xx` seconds for a key before running the command again.
I usually use a sub-second value.
- `--doclear` : Clear the screen afterwards (`--nodoclear` to disable it)

Example: `doit echo hello world`
<pre>
Expand Down
9 changes: 9 additions & 0 deletions demoscript/demoscript
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function doit() {
local norepaint=""
local slowoutput=""
local showcmd=""
local doClear="${DOCLEAR:-}"

while [[ "$1" == "--"* ]]; do
opt="$1"
Expand All @@ -137,6 +138,8 @@ function doit() {
--norepaint ) norepaint="1" ;;
--slowoutput ) slowoutput="1" ;;
--showcmd* ) showcmd="${opt#*=}" ;;
--doclear ) doClear="1" ;;
--nodoclear ) doClear="" ;;
esac
done

Expand Down Expand Up @@ -303,6 +306,12 @@ function doit() {
break

done

if [[ -n "$doClear" ]]; then
echo -n $bold"$"$normal" "
pause
clear
fi
}

function background() {
Expand Down

0 comments on commit 3d4ae27

Please sign in to comment.