blobutil: cleaner coding style

reduced indentation

main() on top

top-down logic

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe 2023-05-18 10:09:15 +01:00
parent c08e3258cb
commit e62215718c
1 changed files with 28 additions and 23 deletions

View File

@ -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 $@