Skip to content
Permalink
Browse files

Categorized help/usage and alphabetized category listing; added ‘cate…

…gories’ command; list help/usage also when no command/options specified
  • Loading branch information...
darwinz committed Nov 21, 2016
1 parent 23fda40 commit 144460cb25eaa223f3c51649e83d7074e2532a70
Showing with 302 additions and 230 deletions.
  1. +2 −1 .gitignore
  2. +73 −78 mac
  3. +227 −151 mac-cli/misc/help
@@ -1,4 +1,5 @@
.DS_Store
.idea/
.idea/workspace.xml
.phpstorm.meta.php
.phpstorm.meta.php
*.iml
151 mac
@@ -17,65 +17,38 @@ MAC="$(dirname "$0")"
#--------------------------------------------------------------------
# Configuration
#--------------------------------------------------------------------
cli_path="/usr/local/bin/"
plugins_path="/usr/local/bin/mac-cli/"
mysql="/Applications/MAMP/Library/bin/mysql"
mysql_socket="/Applications/MAMP/tmp/mysql/mysql.sock"
mysql_user="root"
mysql_password="root"
mysqldump="/Applications/MAMP/Library/bin/mysqldump"
dropbox_folder="/Users/$(id -u -n)/Dropbox/"
php="/Applications/MAMP/bin/php/php5.5.26/bin/php"
php_cli=$(which php)
github_email_account=$(git config -l | grep user.email= | cut -d "=" -f2)
echocommand="false"
pref_editor="vi"

export cli_path
export plugins_path
export mysql
export mysql_socket
export mysql_user
export mysql_password
export mysqldump
export dropbox_folder
export php
export php_cli
export github_email_account
export echocommand
export pref_editor
export cli_path="/usr/local/bin/"
export plugins_path="/usr/local/bin/mac-cli/"
export mysql="/Applications/MAMP/Library/bin/mysql"
export mysql_socket="/Applications/MAMP/tmp/mysql/mysql.sock"
export mysql_user="root"
export mysql_password="root"
export mysqldump="/Applications/MAMP/Library/bin/mysqldump"
export dropbox_folder="/Users/$(id -u -n)/Dropbox/"
export php="/Applications/MAMP/bin/php/php5.5.26/bin/php"
export php_cli=$(which php)
export github_email_account=$(git config -l | grep user.email= | cut -d "=" -f2)
export echocommand="false"
export pref_editor="vi"

#--------------------------------------------------------------------
# Parameters
#--------------------------------------------------------------------
fn=$1
firstParameter=$2
secondParameter=$3
allParameters=${@:2}

export fn
export firstParameter
export secondParameter
export allParameters
export fn=$1
export firstParameter=$2
export secondParameter=$3
export allParameters=${@:2}

#--------------------------------------------------------------------
# Colors
#--------------------------------------------------------------------
GREEN='\033[0;32m'
GRAY='\033[0;37m'
LIGHTBLUE='\033[1;34m'
LIGHTGREEN='\033[1;32m'
WHITEBOLD='\033[1;37m'
RED='\033[1;31m'
NC='\033[0m' # No Color

export GREEN
export GRAY
export LIGHTBLUE
export LIGHTGREEN
export WHITEBOLD
export RED
export NC
export GREEN='\033[0;32m'
export GRAY='\033[0;37m'
export LIGHTBLUE='\033[1;34m'
export LIGHTGREEN='\033[1;32m'
export WHITEBOLD='\033[1;37m'
export RED='\033[1;31m'
export NC='\033[0m' # No Color

#--------------------------------------------------------------------
# List of Commands
@@ -84,6 +57,22 @@ export NC
COMMANDS=(
list
help
usage
categories
general
search
network
lamp
ssh
webdev
performance
terminal
git
web_utilities
homebrew
xcode
image
magento
update
lock
restart
@@ -200,43 +189,49 @@ COMMANDS=(
)
## ---- END OF COMMANDS; Comment required for bash_completion------

if [ -z "$fn" ]; then
if [ -z "$fn" ] || [[ "$#" -lt "1" ]]; then
fn="list"
fi

if [[ ! " ${COMMANDS[@]} " =~ " ${fn} " ]]; then
echo "${RED}Command not found: ${NC}"
echo "$fn"

if [ ! -z "$allParameters" -a "$allParameters" != " " ]; then
echo "${RED}\nParameters: ${NC}"
echo "$allParameters"
fi
fi

#--------------------------------------------------------------------
# Help
#--------------------------------------------------------------------

# Documentation / Help
"$MAC/mac-cli/misc/help"
source "$MAC/mac-cli/misc/help"

#--------------------------------------------------------------------
# Catch command not found
#--------------------------------------------------------------------

if [[ ! " ${COMMANDS[@]} " =~ " ${fn} " ]]; then
echo "${RED}Command not found: '${fn}' $(test ! -z "$allParameters" -a "$allParameters" != " " && echo "\nParameters: $allParameters" || echo "")${NC}"
read -p "Choose a category for which to list help/usage... ($(categoriesList)) " category # Ask user for a category to print usage

if [ ! -z "${category}" ]; then
echo "$(usageList ${category})\n" # Show help/usage for user-selected category
echo "$(printAdditionalHelp)"
else
kill -INT $$ # Exit
fi
fi

#--------------------------------------------------------------------
# Plugins
#--------------------------------------------------------------------

"$MAC/mac-cli/plugins/brew"
"$MAC/mac-cli/plugins/general"
"$MAC/mac-cli/plugins/git"
"$MAC/mac-cli/plugins/image"
"$MAC/mac-cli/plugins/brew"
"$MAC/mac-cli/plugins/iterm"
"$MAC/mac-cli/plugins/lamp"
"$MAC/mac-cli/plugins/magento"
"$MAC/mac-cli/plugins/network"
"$MAC/mac-cli/plugins/performance"
"$MAC/mac-cli/plugins/search"
"$MAC/mac-cli/plugins/ssh"
"$MAC/mac-cli/plugins/web"
"$MAC/mac-cli/plugins/xcode"
"$MAC/mac-cli/plugins/volume"
source "$MAC/mac-cli/plugins/brew"
source "$MAC/mac-cli/plugins/general"
source "$MAC/mac-cli/plugins/git"
source "$MAC/mac-cli/plugins/image"
source "$MAC/mac-cli/plugins/brew"
source "$MAC/mac-cli/plugins/iterm"
source "$MAC/mac-cli/plugins/lamp"
source "$MAC/mac-cli/plugins/magento"
source "$MAC/mac-cli/plugins/network"
source "$MAC/mac-cli/plugins/performance"
source "$MAC/mac-cli/plugins/search"
source "$MAC/mac-cli/plugins/ssh"
source "$MAC/mac-cli/plugins/web"
source "$MAC/mac-cli/plugins/xcode"
source "$MAC/mac-cli/plugins/volume"

0 comments on commit 144460c

Please sign in to comment.
You can’t perform that action at this time.