mirror of
https://tildegit.org/tomasino/pb.git
synced 2024-11-20 03:25:54 +01:00
option errors show usage
This commit is contained in:
parent
2a8915fc3f
commit
43cc89a39c
@ -1,4 +1,4 @@
|
|||||||
pb ![calver](https://img.shields.io/badge/calver-2020.01.20-22bfda.svg?style=flat-square) ![status](https://img.shields.io/badge/status-working-green.svg?style=flat-square) ![license](https://img.shields.io/badge/license-GPL3-blue.svg?style=flat-square)
|
pb ![calver](https://img.shields.io/badge/calver-2020.06.10-22bfda.svg?style=flat-square) ![status](https://img.shields.io/badge/status-working-green.svg?style=flat-square) ![license](https://img.shields.io/badge/license-GPL3-blue.svg?style=flat-square)
|
||||||
------
|
------
|
||||||
|
|
||||||
**pb** is a helper utility for using 0x0 pastebin services
|
**pb** is a helper utility for using 0x0 pastebin services
|
||||||
|
16
pb
16
pb
@ -1,9 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# init variables
|
# init variables
|
||||||
version="v2020.01.20"
|
version="v2020.06.10"
|
||||||
ENDPOINT="https://ttm.sh"
|
ENDPOINT="https://ttm.sh"
|
||||||
flag_options="hvcufs::x"
|
flag_options=":hvcufs::x"
|
||||||
flag_version=0
|
flag_version=0
|
||||||
flag_help=0
|
flag_help=0
|
||||||
flag_file=0
|
flag_file=0
|
||||||
@ -31,6 +31,12 @@ OPTIONAL FLAGS:
|
|||||||
END
|
END
|
||||||
}
|
}
|
||||||
|
|
||||||
|
show_usage() {
|
||||||
|
cat > /dev/stdout << END
|
||||||
|
usage: pb [-hfvcux] [-s server_address] filename
|
||||||
|
END
|
||||||
|
}
|
||||||
|
|
||||||
# helper for program exit, supports error codes and messages
|
# helper for program exit, supports error codes and messages
|
||||||
die () {
|
die () {
|
||||||
msg="$1"
|
msg="$1"
|
||||||
@ -59,14 +65,16 @@ fi
|
|||||||
|
|
||||||
# attempt to parse options or die
|
# attempt to parse options or die
|
||||||
if ! parsed=$(getopt ${flag_options} "$@"); then
|
if ! parsed=$(getopt ${flag_options} "$@"); then
|
||||||
die "Invalid input" 2
|
printf "pb: unknown option\\n"
|
||||||
|
show_usage
|
||||||
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# handle options
|
# handle options
|
||||||
eval set -- "${parsed}"
|
eval set -- "${parsed}"
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h)
|
-h|?)
|
||||||
flag_help=1
|
flag_help=1
|
||||||
;;
|
;;
|
||||||
-v)
|
-v)
|
||||||
|
Loading…
Reference in New Issue
Block a user