commit e7476006e1e753fc4f3e496d9b099b494ed51562
parent 6fa2dc469a805e2189a4ffc468260f5b1320e9b7
Author: parazyd <parazyd@dyne.org>
Date: Thu, 1 Mar 2018 01:18:36 +0100
Simplify usage() in shell scripts.
Diffstat:
5 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/bin/rpabook b/bin/rpabook
@@ -4,10 +4,9 @@ profile="${RPPROFILE:-$HOME/.rp/default}"
. "$HOME"/.rp/rplib/common.sh
usage() {
- einfo "usage: $(basename $0) [-a] [-c]"
- einfo " -a: add to abook"
- einfo " -c: completion (used from mutt)"
- exit 1
+ edie "usage: $(basename $0) [-a] [-c]
+ -a: add to abook
+ -c: completion (used from mutt)"
}
comp() {
diff --git a/bin/rppeek b/bin/rppeek
@@ -7,8 +7,7 @@ profile="${RPPROFILE:-$HOME/.rp/default}"
. "$profile"/config
usage() {
- einfo "usage: $(basename $0) [folder]"
- exit 1
+ edie "usage: $(basename $0) [folder]"
}
for i in $@; do
diff --git a/bin/rpsend b/bin/rpsend
@@ -7,12 +7,10 @@ profile="${RPPROFILE:-$HOME/.rp/default}"
. "$profile"/config
usage() {
- einfo "usage: $(basename $0) [-n] [-l] [-a]"
- einfo " -n: dry run"
- einfo " -l: list outbox"
- einfo " -a: send all"
- einfo " It is also possible to pipe an email to $(basename $0)'s stdin.'"
- exit 1
+ edie "usage: $(basename $0) [-n] [-l] [-a] < email
+ -n: dry run
+ -l: list outbox
+ -a: send all"
}
listoutbox() {
diff --git a/bin/rpsieve b/bin/rpsieve
@@ -4,10 +4,9 @@ profile="${RPPROFILE:-$HOME/.rp/default}"
. "$profile"/../rplib/common.sh
usage() {
- einfo "usage: $(basename $0) [-e] [-u]"
- einfo " -e: edit filters.txt before continuing"
- einfo " -u: upload filters.sieve when done"
- exit 1
+ edie "usage: $(basename $0) [-e] [-u]
+ -e: edit filters.txt before continuing
+ -u: upload filters.sieve when done"
}
for i in $@; do
diff --git a/bin/rpsync b/bin/rpsync
@@ -7,10 +7,9 @@ profile="${RPPROFILE:-$HOME/.rp/default}"
. "$profile"/config
usage() {
- einfo "usage: $(basename $0) [-n] [-d]"
- einfo " -n: dry run"
- einfo " -d: delete remote emails"
- exit 1
+ edie "usage: $(basename $0) [-n] [-d]
+ -n: dry run
+ -d: delete remote emails"
}
for i in $@; do