add usage() and die()

This commit is contained in:
NRK
2021-04-12 03:31:26 +06:00
parent f0d5cc8e75
commit fc7c8b9cb1

21
sxbm
View File

@ -24,3 +24,24 @@ ENCRYPTION="0"
# Auto fetch title. 1 to enable, 0 to disable
TITLE_FETCH="1"
die(){
[ -z "$1" ] ||
printf "$@\n" > /dev/stderr
exit 1
}
usage(){
printf "Usage: sxbm <command> [<args>]\n"
printf "
COMMANDS:
add <link> [title] [+tags]
ls|list [-c|--disable-colors] [title] [+tags]
open [-f|--force] <line_num|title|+tags>
rm|remove [-f|--force] <line_num|title|+tags>
edit [line_num|title|+tags]
-h|--help print this text and exit
-v|--version print the version and exit\n\n"
}
[ -z "$1" ] && usage && die