mirror of
https://tildegit.org/envs/pb.git
synced 2025-04-11 17:45:51 +00:00
option errors show usage
This commit is contained in:
parent
2a8915fc3f
commit
43cc89a39c
3 changed files with 14 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
|||
pb   
|
||||
pb   
|
||||
------
|
||||
|
||||
**pb** is a helper utility for using 0x0 pastebin services
|
||||
|
|
16
pb
16
pb
|
@ -1,9 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
# init variables
|
||||
version="v2020.01.20"
|
||||
version="v2020.06.10"
|
||||
ENDPOINT="https://ttm.sh"
|
||||
flag_options="hvcufs::x"
|
||||
flag_options=":hvcufs::x"
|
||||
flag_version=0
|
||||
flag_help=0
|
||||
flag_file=0
|
||||
|
@ -31,6 +31,12 @@ OPTIONAL FLAGS:
|
|||
END
|
||||
}
|
||||
|
||||
show_usage() {
|
||||
cat > /dev/stdout << END
|
||||
usage: pb [-hfvcux] [-s server_address] filename
|
||||
END
|
||||
}
|
||||
|
||||
# helper for program exit, supports error codes and messages
|
||||
die () {
|
||||
msg="$1"
|
||||
|
@ -59,14 +65,16 @@ fi
|
|||
|
||||
# attempt to parse options or die
|
||||
if ! parsed=$(getopt ${flag_options} "$@"); then
|
||||
die "Invalid input" 2
|
||||
printf "pb: unknown option\\n"
|
||||
show_usage
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# handle options
|
||||
eval set -- "${parsed}"
|
||||
while true; do
|
||||
case "$1" in
|
||||
-h)
|
||||
-h|?)
|
||||
flag_help=1
|
||||
;;
|
||||
-v)
|
||||
|
|
2
pb.1
2
pb.1
|
@ -1,4 +1,4 @@
|
|||
.TH PB 1 "20 January 2020" "v2020.01.20"
|
||||
.TH PB 1 "10 June 2020" "v2020.06.10"
|
||||
|
||||
.SH NAME
|
||||
pb \- a helper utility for using 0x0 pastebin services
|
||||
|
|
Loading…
Add table
Reference in a new issue