From 3a5e42fc90730ba5ae8fcd0cfd5d7b0109613a25 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Wed, 28 Oct 2015 16:10:06 -0400 Subject: main(): Replace show_menu() with an argument --- (limited to 'src') diff --git a/src/main.sh b/src/main.sh index c4b7491..42e4d96 100644 --- a/src/main.sh +++ b/src/main.sh @@ -19,19 +19,23 @@ set -u usage() { - printf 'Usage: %s [option ...]\n' "${0}" + printf 'Usage: %s [option ...] \n' "${0}" } help() { usage cat < Log output to + +Actions: + update Update firmware EOF } @@ -50,6 +54,7 @@ main() { local opt= local ui='cli' + local action= unset OPTARG while getopts 'hVi:o:' opt; do @@ -73,10 +78,18 @@ main() done shift $(($OPTIND - 1)) - if [ ${#} -ne 0 ]; then + if [ ${#} -ne 1 ]; then usage >&2 exit 1 fi + action="${1}" + + case "${action}" in + 'update');; + *) + usage >&2 + exit 1 + esac if ! init_ui "${ui}"; then exit 1 @@ -84,18 +97,13 @@ main() srand $(expr ${$} + $(date '+%s')) init_temp_dir - while :; do - case "$(show_menu 'Firmware Manager' 'Update firmware' \ - 'Exit')" in - 0) - do_update - ;; - 1) - info 'Exiting' - break - ;; - esac - done + case "${action}" in + 'update') + do_update + ;; + esac + + info 'Exiting' fini_temp_dir exit_ui -- cgit v0.9.1