aboutsummaryrefslogtreecommitdiff
path: root/bin/pre
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-05-09 09:16:29 -0300
committerEuAndreh <eu@euandre.org>2024-05-09 09:16:29 -0300
commitcb3e6e922465717e360cedbe80f2420cc50e397d (patch)
treea0e2abd36b11acef9bf6e230a3f69843a0a59595 /bin/pre
parentbin/backup: Further simplify this backup script (diff)
downloaddotfiles-cb3e6e922465717e360cedbe80f2420cc50e397d.tar.gz
dotfiles-cb3e6e922465717e360cedbe80f2420cc50e397d.tar.xz
bin/...: Move utilities to the dedicated "eut" package
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