mirror of https://git.envs.net/envs/burrow.git
arguement parsing exclusively for setting flags. logic in main
This commit is contained in:
parent
c75383377d
commit
68ac3f0053
28
burrow
28
burrow
|
@ -18,10 +18,13 @@ config_git_push=false
|
|||
|
||||
# vars from flags
|
||||
flag_debug=0
|
||||
flag_version=0
|
||||
flag_help=0
|
||||
|
||||
# vars from args
|
||||
arg_options=hvd
|
||||
arg_longoptions=help,version,debug
|
||||
arg_shortlist=0
|
||||
arg_recipe=0
|
||||
arg_phlog=0
|
||||
arg_create_config=0
|
||||
|
@ -72,11 +75,11 @@ function parse_input() {
|
|||
while true; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
show_help
|
||||
flag_help=1
|
||||
shift
|
||||
;;
|
||||
-v|--version)
|
||||
echo "$version"
|
||||
flag_version=1
|
||||
shift
|
||||
;;
|
||||
-d|--debug)
|
||||
|
@ -103,10 +106,7 @@ function parse_input() {
|
|||
do
|
||||
argc=${arg,,}
|
||||
case $argc in
|
||||
"shortlist")
|
||||
echo "phlog recipe create-config update-git"
|
||||
exit 0
|
||||
;;
|
||||
"shortlist") arg_shortlist=1 ;;
|
||||
"phlog") arg_phlog=1 ;;
|
||||
"recipe") arg_recipe=1 ;;
|
||||
"create-config") arg_create_config=1 ;;
|
||||
|
@ -306,6 +306,22 @@ function update_git() {
|
|||
function main() {
|
||||
parse_input "$@"
|
||||
|
||||
if [[ ${arg_shortlist} ]]
|
||||
then
|
||||
echo "phlog recipe create-config update-git"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ${flag_version} -gt 0 ]]
|
||||
then
|
||||
echo "$version"
|
||||
fi
|
||||
|
||||
if [[ ${flag_help} -gt 0 ]]
|
||||
then
|
||||
show_help
|
||||
fi
|
||||
|
||||
if [[ ${flag_debug} -gt 0 ]]
|
||||
then
|
||||
set -x
|
||||
|
|
Loading…
Reference in New Issue