diff options
author | P. J. McDermott <pj@pehjota.net> | 2015-10-28 16:10:06 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2015-10-28 16:10:06 (EDT) |
commit | 3a5e42fc90730ba5ae8fcd0cfd5d7b0109613a25 (patch) | |
tree | a70347aeb9b0fba8e2149902c72d71d227b037cb /src | |
parent | 857fcfcd283d97db8a930076f3076f50115ede3f (diff) | |
download | firman.sh-3a5e42fc90730ba5ae8fcd0cfd5d7b0109613a25.zip firman.sh-3a5e42fc90730ba5ae8fcd0cfd5d7b0109613a25.tar.gz firman.sh-3a5e42fc90730ba5ae8fcd0cfd5d7b0109613a25.tar.bz2 |
main(): Replace show_menu() with an argument
Diffstat (limited to 'src')
-rw-r--r-- | src/main.sh | 36 |
1 files changed, 22 insertions, 14 deletions
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 ...] <action>\n' "${0}" } help() { usage cat <<EOF + Options: -h Display this information -V Display version information -i {cli|tui} Select either a textual user interface or a command line interface (default: cli) -o <file> Log output to <file> + +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 |