aboutsummaryrefslogtreecommitdiff
path: root/bin/pre
diff options
context:
space:
mode:
Diffstat (limited to 'bin/pre')
-rwxr-xr-xbin/pre82
1 files changed, 0 insertions, 82 deletions
diff --git a/bin/pre b/bin/pre
deleted file mode 100755
index e610fab..0000000
--- a/bin/pre
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/sh
-set -eu
-
-usage() {
- cat <<-'EOF'
- Usage:
- pre [-c COLOR] PREFIX
- pre -h
- EOF
-}
-
-help() {
- cat <<-'EOF'
-
-
- Options:
- -c COLOR ANSI color to be used on the prefix text
- -h, --help show this message
-
- PREFIX the string to insert at the beginning
-
-
- Prefix STDIN with PREFIX.
-
-
- Examples:
-
- Prefix with 'database':
-
- $ ./run-db.sh | pre 'database'
-
-
- Prefix with yellow 'numbers':
-
- $ seq 10 | pre -c yellow numbers
- EOF
-}
-
-for flag in "$@"; do
- case "$flag" in
- (--)
- break
- ;;
- (--help)
- usage
- help
- exit
- ;;
- (*)
- ;;
- esac
-done
-
-COLOR=''
-while getopts 'c:h' flag; do
- case "$flag" in
- (c)
- COLOR="$OPTARG"
- ;;
- (h)
- usage
- help
- exit
- ;;
- (*)
- usage >&2
- exit 2
- ;;
- esac
-done
-shift $((OPTIND - 1))
-
-PREFIX="${1:-}"
-eval "$(assert-arg -- "$PREFIX" 'PREFIX')"
-
-while read -r line; do
- if [ -z "$COLOR" ]; then
- printf '%s: %s\n' "$PREFIX" "$line"
- else
- printf '%s: %s\n' "$(color -c "$COLOR" "$PREFIX")" "$line"
- fi
-done