diff options
author | Leah Rowe <leah@libreboot.org> | 2023-05-18 10:09:15 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2023-05-18 10:09:57 +0100 |
commit | e62215718ca4aa8df13c101690f58619e82b9b73 (patch) | |
tree | d6e9710dbbbf58322a00b74ad25687cb55f8734b | |
parent | c08e3258cbada3f192c19349cd7d8afb62025c8f (diff) |
blobutil: cleaner coding style
reduced indentation
main() on top
top-down logic
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rwxr-xr-x | blobutil | 51 |
1 files changed, 28 insertions, 23 deletions
@@ -1,13 +1,37 @@ #!/bin/sh # SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com> +# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org> # SPDX-License-Identifier: GPL-3.0-only -./.gitcheck - script_dir="resources/scripts/blobs" modes=$(ls -1 ${script_dir}) -Print_help(){ +main() +{ + if [ $# -lt 1 ]; then + printf "%s: Error: you must specify a mode\n" $0 + usage + exit 1 + fi + + ./.gitcheck + + mode=${1} + shift + args=$@ + + if [ ! -f "${script_dir}/${mode}" ]; then + printf "Error: No mode ${mode}\n" + usage + exit 1 + fi + + ./${script_dir}/${mode} ${args} + + ./.gitcheck clean +} + +usage(){ cat <<- EOF Usage: ./blobutil [mode] <options> Example: ./blobutil download x230_12mb @@ -22,23 +46,4 @@ Print_help(){ EOF } - -if [ $# -gt 0 ]; then - mode="${1}" - shift - args="$@" - - if [ ! -f "${script_dir}/${mode}" ]; then - printf "Error: No mode ${mode}\n" - Print_help - exit 1 - else - ./${script_dir}/${mode} ${args} - fi - -else - printf 'Error: You must specify a mode\n' - Print_help -fi - -./.gitcheck clean +main $@ |