Skip to content

Commit

Permalink
menu: add help and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ukkopahis committed Jun 17, 2022
1 parent 19786e8 commit be46277
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
2 changes: 2 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ do
--no-ask) NOASKCONFIRM="true"
;;
--*) echo "bad option $1"
echo "USAGE: $0 [--no-ask]"
exit 1
;;
esac
shift
Expand Down
42 changes: 29 additions & 13 deletions menu.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# vim: noexpandtab

CURRENT_BRANCH=$(git name-rev --name-only HEAD)

Expand All @@ -14,9 +15,6 @@ VGET_CMD="$PYTHON_CMD ./scripts/python_deps_check.py"

sys_arch=$(uname -m)

# ----------------------------------------------
# Helper functions
# ----------------------------------------------
function command_exists() {
command -v "$@" > /dev/null 2>&1
}
Expand Down Expand Up @@ -359,13 +357,7 @@ function do_env_checks() {
fi
}

# ----------------------------------------------
# Menu bootstrap entry point
# ----------------------------------------------

if [[ "$*" == *"--no-check"* ]]; then
echo "Skipping preflight checks."
else
function do_checks() {
do_project_checks
do_env_checks
do_python3_checks
Expand All @@ -384,14 +376,27 @@ else
echo " rm .docker_notinstalled || rm .docker_outofdate || rm .project_outofdate"
echo ""
fi
fi
}

function do_help() {
echo "USAGE:
$0 [OPTIONS...]"
echo $'OPTIONS:
--branch <name> override branch to check for updates
(default: current branch)
--no-check don\'t run any environment or git checks
--run-env-setup try to make required user&group changes
--encoding <enc> set encoding for menu'
}

while test $# -gt 0
do
case "$1" in
--branch) CURRENT_BRANCH=${2:-$(git name-rev --name-only HEAD)}
;;
--no-check) echo ""
--no-check)
NO_CHECKS=true
echo "Skipping preflight checks."
;;
--run-env-setup) # Sudo cannot be run from inside functions.
echo "Setting up environment:"
Expand All @@ -411,12 +416,23 @@ do
;;
--encoding) ENCODING_TYPE=$2
;;
--*) echo "bad option $1"
--help)
do_help
exit 1
;;
--*)
echo "ERROR: unknown option: $1"
do_help
exit 1
;;
esac
shift
done

if [[ -z "$NO_CHECKS" ]]; then
do_checks
fi

# This section is temporary, it's just for notifying people of potential breaking changes.
if [[ -f .new_install ]]; then
echo "Existing installation detected."
Expand Down

0 comments on commit be46277

Please sign in to comment.