-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathecho-verbose
executable file
·61 lines (46 loc) · 1.07 KB
/
echo-verbose
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
function echo_verbose() (
source "$DOROTHY/sources/stdinargs.bash"
# =====================================
# Arguments
function help {
cat <<-EOF >/dev/stderr
ABOUT:
Quickly output inputs and their position.
USAGE:
echo-verbose [...options] [--] ...<input>
echo-lines ...<input> | echo-verbose [...options]
OPTIONS:
$(stdinargs_options_help --)
EXAMPLE:
echo-verbose -- a b c
[0] = [a]
[1] = [b]
[2] = [c]
echo-lines -- a b c | echo-verbose --stdin
[0] = [a]
[1] = [b]
[2] = [c]
EOF
if [[ $# -ne 0 ]]; then
echo-error "$@"
fi
return 22 # EINVAL 22 Invalid argument
}
# =====================================
# Action
# on each input, update the position, and output
local input_index=0
function on_input {
__print_lines "[$input_index] = [$1]"
input_index="$((input_index + 1))"
}
function on_no_input {
echo-style --dim='[ nothing provided ]'
}
stdinargs "$@"
)
# fire if invoked standalone
if [[ $0 == "${BASH_SOURCE[0]}" ]]; then
echo_verbose "$@"
fi