-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switch secondary global default to false
- Loading branch information
Showing
5 changed files
with
191 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bash | ||
|
||
#=============================================================================================== | ||
# HELPER FUNCTIONS | ||
#=============================================================================================== | ||
|
||
# Global Variables | ||
source ./bin/globals | ||
|
||
# Get Apple ID Username (email) | ||
getAccountId() { | ||
defaults read MobileMeAccounts Accounts | sed -n -e 's/.*AccountID = \"\(.*\)\"\;/\1/p' | ||
} | ||
|
||
# Display Nicely Formatted Message | ||
message() { | ||
if [ "$1" = "info" ]; then | ||
local msg="${RED}\n\n${EMOJI_INFO} ${2}${NC}\n\n\n" | ||
elif [ "$1" = "warning" ]; then | ||
local msg="${RED}\n\n${EMOJI_WARNING} ${2}${NC}\n\n\n" | ||
elif [ "$1" = "fail" ]; then | ||
local msg="${RED}\n\n${EMOJI_FAIL} ${2}${NC}\n\n\n" | ||
elif [ "$1" = "error" ]; then | ||
local msg="${RED}\n\n${EMOJI_ERROR} ${2}${NC}\n\n\n" | ||
else | ||
local msg="${GREEN}\n\n${EMOJI_CHECKMARK} ${1}${NC}\n\n\n" | ||
fi | ||
|
||
shift | ||
printf "${msg}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/usr/bin/env bash | ||
|
||
#=============================================================================================== | ||
# COMMAND LINE OPTIONS | ||
#=============================================================================================== | ||
|
||
# Global Variables | ||
source ./bin/globals | ||
|
||
#----------------------------------------------------------------------------------------------- | ||
# HELPER FUNCTIONS | ||
|
||
# Handle CLI Arguments | ||
handle_arguments() { | ||
# Set Additional Defaults | ||
if [ $# -ne 0 ]; then | ||
BREW_FILE=${1} | ||
echo "Using Brewfile '${BREW_FILE}'" | ||
fi | ||
} | ||
|
||
# Bash Builtin Getopts | ||
handle_getopts() { | ||
OPTIONS=":EFhi:s" | ||
|
||
# No Arguments Runs FULL Install | ||
if [ $# -eq 0 ]; then | ||
RUN_SECONDARY=true | ||
fi | ||
|
||
# Handle Options | ||
while getopts ${OPTIONS} option; do | ||
case "${option}" in | ||
E) | ||
SETUP_MODE="ESSENTIALS" | ||
;; | ||
F) | ||
# Global Default: SETUP_MODE="FULL" | ||
RUN_SECONDARY=true | ||
;; | ||
i) | ||
SETUP_MODE=$(echo ${OPTARG} | tr [:lower:] [:upper:]) | ||
case "${SETUP_MODE}" in | ||
FULL) | ||
# Global Default: SETUP_MODE="FULL" | ||
RUN_SECONDARY=true | ||
;; | ||
ESSENTIALS) | ||
;; | ||
*) | ||
echo "Incorrect option provided for -i: ${OPTARG}" | ||
usage | ||
;; | ||
esac | ||
;; | ||
s) | ||
RUN_SECONDARY=true | ||
;; | ||
\?) | ||
echo "Invalid Option: -${OPTARG}" | ||
usage | ||
;; | ||
:) | ||
echo "Invalid Option: -${OPTARG} requires an argument" | ||
usage | ||
;; | ||
h | *) | ||
usage | ||
;; | ||
esac | ||
done | ||
|
||
shift $((OPTIND -1)) # remove options already handled by getopts from $@ | ||
|
||
handle_arguments "$@" | ||
} | ||
|
||
# Prettify Options Output Message | ||
print_option() { | ||
printf "\t%s\t%s\n" "${1}" "${2}" | expand -t 4,28 | ||
} | ||
|
||
# Usage Message | ||
usage() { | ||
echo -e "\nUsage: $(basename "$0") [Options] Brewfile\n" | ||
echo -e "\nRunning install without any options below will run a FULL setup by default.\n" | ||
echo -e "\nOptions:\n" | ||
print_option "-F" "Full install setup (Defaults: -s=true)" | ||
print_option "-E" "Essentials only installations" | ||
print_option "-i [full|essentials]" "More explicit install type declaration" | ||
print_option "-s" "Run secondary installation (Default: false)" | ||
print_option "-h" "Prints this usage message" | ||
echo -e "\nArguments:\n" | ||
print_option "Brewfile" "Path to Brew bundle file (Default: '${BREW_FILE}')" | ||
echo -e "\n" | ||
1>&2 | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
#=============================================================================================== | ||
# GLOBAL ENVIRONMENT VARIABLES | ||
#=============================================================================================== | ||
|
||
# General | ||
SETUP_MODE="FULL" # DEFAULT: Full setup - installs everything in Brewfile and secondary | ||
RUN_SECONDARY=false | ||
|
||
# Setup Files | ||
BREW_CASKS="./src/casks.txt" | ||
BREW_FILE="./src/Brewfile" | ||
BREW_FORMULAE="./src/formulae.txt" | ||
BREW_TAPS="./src/taps.txt" | ||
MAC_APPS="./src/apps.txt" | ||
|
||
# Color Outputs | ||
GREEN="\033[0;32m" | ||
RED="\033[0;31m" | ||
NC="\033[0m" | ||
|
||
# Emojis Hex | ||
EMOJI_CHECKMARK="\xe2\x9c\x85" | ||
EMOJI_ERROR="\xe2\x9b\x94\xef\xb8\x8f" | ||
EMOJI_FAIL="\xe2\x9d\x8c" | ||
EMOJI_INFO="\xe2\x84\xb9\xef\xb8\x8f" | ||
EMOJI_WARNING="\xe2\x9b\x94\xef\xb8\x8f" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
brewsci/bio | ||
homebrew/bundle | ||
brewsci/science | ||
caskroom/versions |