Skip to content

Commit 19351ce

Browse files
committed
menu: add help and cleanup
1 parent 732889a commit 19351ce

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
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 & 10 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

@@ -359,13 +360,7 @@ function do_env_checks() {
359360
fi
360361
}
361362

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

389395
while test $# -gt 0
390396
do
391397
case "$1" in
392398
--branch) CURRENT_BRANCH=${2:-$(git name-rev --name-only HEAD)}
393399
;;
394-
--no-check) echo ""
400+
--no-check)
401+
NO_CHECKS=true
402+
echo "Skipping preflight checks."
395403
;;
396404
--run-env-setup) # Sudo cannot be run from inside functions.
397405
echo "Setting up environment:"
@@ -411,12 +419,23 @@ do
411419
;;
412420
--encoding) ENCODING_TYPE=$2
413421
;;
414-
--*) echo "bad option $1"
422+
--help)
423+
do_help
424+
exit 1
425+
;;
426+
--*)
427+
echo "ERROR: unknown option: $1"
428+
do_help
429+
exit 1
415430
;;
416431
esac
417432
shift
418433
done
419434

435+
if [[ -z "$NO_CHECKS" ]]; then
436+
do_checks
437+
fi
438+
420439
# This section is temporary, it's just for notifying people of potential breaking changes.
421440
if [[ -f .new_install ]]; then
422441
echo "Existing installation detected."

0 commit comments

Comments
 (0)