mirror of https://git.envs.net/envs/burrow.git
removed longopts completely for portability
This commit is contained in:
parent
359dea788b
commit
87ffadc19a
|
@ -10,12 +10,6 @@
|
||||||
|
|
||||||
* bash 4+
|
* bash 4+
|
||||||
|
|
||||||
#### Optional
|
|
||||||
|
|
||||||
* GNU getopt
|
|
||||||
|
|
||||||
* Required to use long named switches, like --version or --help instead of -v and -h.
|
|
||||||
|
|
||||||
### Install
|
### Install
|
||||||
|
|
||||||
`sudo make install`
|
`sudo make install`
|
||||||
|
|
37
burrow
37
burrow
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# shellcheck disable=SC1117
|
||||||
|
|
||||||
version="v1.4.0"
|
version="v1.4.0"
|
||||||
|
|
||||||
|
@ -41,7 +42,6 @@ flag_noautoindent=0
|
||||||
|
|
||||||
# vars from args
|
# vars from args
|
||||||
arg_options="hvd"
|
arg_options="hvd"
|
||||||
arg_longoptions="help,version,debug,noautoindent"
|
|
||||||
arg_shortlist=0
|
arg_shortlist=0
|
||||||
arg_recipe=0
|
arg_recipe=0
|
||||||
arg_phlog=0
|
arg_phlog=0
|
||||||
|
@ -75,9 +75,9 @@ COMMANDS:
|
||||||
update-burrow Auto-update this application in its local folder
|
update-burrow Auto-update this application in its local folder
|
||||||
|
|
||||||
OPTIONAL FLAGS:
|
OPTIONAL FLAGS:
|
||||||
-h, --help Show this help
|
-h Show this help
|
||||||
-v, --version Show current version info
|
-v Show current version info
|
||||||
-d, --debug Debug mode
|
-d Debug mode
|
||||||
|
|
||||||
END
|
END
|
||||||
}
|
}
|
||||||
|
@ -95,19 +95,7 @@ function check_coreutils {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse_input {
|
function parse_input {
|
||||||
if getopt -T > /dev/null -eq 4; then
|
if ! parsed=$(getopt $arg_options "$@"); then
|
||||||
# GNU enhanced getopt is available
|
|
||||||
parsed=$(getopt \
|
|
||||||
--options=$arg_options \
|
|
||||||
--longoptions=$arg_longoptions \
|
|
||||||
--name "$0" \
|
|
||||||
-- "$@")
|
|
||||||
else
|
|
||||||
# Original getopt is available
|
|
||||||
parsed=$(getopt $arg_options "$@")
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
die "Invalid input" 2
|
die "Invalid input" 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -115,22 +103,18 @@ function parse_input {
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h|--help)
|
-h)
|
||||||
flag_help=1
|
flag_help=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-v|--version)
|
-v)
|
||||||
flag_version=1
|
flag_version=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-d|--debug)
|
-d)
|
||||||
flag_debug=1
|
flag_debug=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--noautoindent)
|
|
||||||
flag_noautoindent=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
|
@ -574,11 +558,6 @@ function main {
|
||||||
|
|
||||||
if [[ $arg_shortlist -gt 0 ]]; then
|
if [[ $arg_shortlist -gt 0 ]]; then
|
||||||
out="phlog topic recipe rss edit-config create-config update-burrow update-git -v -h -d"
|
out="phlog topic recipe rss edit-config create-config update-burrow update-git -v -h -d"
|
||||||
# include long options only if using gnu getopt
|
|
||||||
getopt -T > /dev/null
|
|
||||||
if [ $? -eq 4 ]; then
|
|
||||||
out="${out} --version --help --debug --noautointent"
|
|
||||||
fi
|
|
||||||
die "${out}" 0
|
die "${out}" 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
6
burrow.1
6
burrow.1
|
@ -64,13 +64,13 @@ named
|
||||||
or some variation of that name.
|
or some variation of that name.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B -v, --version
|
.B -v
|
||||||
Display current version information.
|
Display current version information.
|
||||||
.TP
|
.TP
|
||||||
.B -d, --debug
|
.B -d
|
||||||
Debug mode.
|
Debug mode.
|
||||||
.TP
|
.TP
|
||||||
.B -h, --help
|
.B -h
|
||||||
Show the help.
|
Show the help.
|
||||||
.SH FILES
|
.SH FILES
|
||||||
.I ~/.config/burrow/config
|
.I ~/.config/burrow/config
|
||||||
|
|
Loading…
Reference in New Issue