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 Apr 29, 2022
1 parent 732889a commit 15dca57
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 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
38 changes: 28 additions & 10 deletions menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,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 +378,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_CHECK=true
echo "Skipping preflight checks."
;;
--run-env-setup) # Sudo cannot be run from inside functions.
echo "Setting up environment:"
Expand All @@ -411,12 +418,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_CHECK" ]]; 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 15dca57

Please sign in to comment.