Skip to content

Commit 8a930eb

Browse files
committed
menu: add help and cleanup
1 parent 732889a commit 8a930eb

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed

install.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ do
1717
--no-ask) NOASKCONFIRM="true"
1818
;;
1919
--*) echo "bad option $1"
20+
echo "USAGE: $0 [--no-ask]"
21+
exit 1
2022
;;
2123
esac
2224
shift

menu.sh

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
# vim: noexpandtab
23

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

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

1516
sys_arch=$(uname -m)
1617

17-
# ----------------------------------------------
18-
# Helper functions
19-
# ----------------------------------------------
2018
function command_exists() {
2119
command -v "$@" > /dev/null 2>&1
2220
}
@@ -359,13 +357,7 @@ function do_env_checks() {
359357
fi
360358
}
361359

362-
# ----------------------------------------------
363-
# Menu bootstrap entry point
364-
# ----------------------------------------------
365-
366-
if [[ "$*" == *"--no-check"* ]]; then
367-
echo "Skipping preflight checks."
368-
else
360+
function do_checks() {
369361
do_project_checks
370362
do_env_checks
371363
do_python3_checks
@@ -384,14 +376,27 @@ else
384376
echo " rm .docker_notinstalled || rm .docker_outofdate || rm .project_outofdate"
385377
echo ""
386378
fi
387-
fi
379+
}
380+
381+
function do_help() {
382+
echo "USAGE:
383+
$0 [OPTIONS...]"
384+
echo $'OPTIONS:
385+
--branch <name> override branch to check for updates
386+
(default: current branch)
387+
--no-check don\'t run any environment or git checks
388+
--run-env-setup try to make required user&group changes
389+
--encoding <enc> set encoding for menu'
390+
}
388391

389392
while test $# -gt 0
390393
do
391394
case "$1" in
392395
--branch) CURRENT_BRANCH=${2:-$(git name-rev --name-only HEAD)}
393396
;;
394-
--no-check) echo ""
397+
--no-check)
398+
NO_CHECKS=true
399+
echo "Skipping preflight checks."
395400
;;
396401
--run-env-setup) # Sudo cannot be run from inside functions.
397402
echo "Setting up environment:"
@@ -411,12 +416,23 @@ do
411416
;;
412417
--encoding) ENCODING_TYPE=$2
413418
;;
414-
--*) echo "bad option $1"
419+
--help)
420+
do_help
421+
exit 1
422+
;;
423+
--*)
424+
echo "ERROR: unknown option: $1"
425+
do_help
426+
exit 1
415427
;;
416428
esac
417429
shift
418430
done
419431

432+
if [[ -z "$NO_CHECKS" ]]; then
433+
do_checks
434+
fi
435+
420436
# This section is temporary, it's just for notifying people of potential breaking changes.
421437
if [[ -f .new_install ]]; then
422438
echo "Existing installation detected."

0 commit comments

Comments
 (0)