diff --git a/lambo b/lambo index a95308cd..ffaf3099 100755 --- a/lambo +++ b/lambo @@ -21,6 +21,9 @@ showhelp() echo "${green} make-config${reset} Generate config file" echo "${green} edit-config${reset} Edit config file" echo " " + echo "${green} make-after${reset} Generate after file" + echo "${green} edit-after${reset} Edit after file" + echo " " echo "${orange}Options (lambo myApplication OPTIONS):" echo "${green} -h, --help${reset} Show brief help" echo "${green} -e, --editor EDITOR${reset} Specify an editor to run '${green}EDITOR .${reset}' with after" @@ -71,6 +74,48 @@ LINK=false' > ~/.lambo/config edit ~/.lambo/config } +editafter() +{ + if [[ ! -f ~/.lambo/after ]]; then + echo "after file does not exist; creating." + + makeafter + return + fi + + edit ~/.lambo/after +} + +makeafter() +{ + if [[ -f ~/.lambo/after ]]; then + echo "after file already exists." + quit + fi + + if [[ ! -d ~/.lambo ]]; then + mkdir ~/.lambo + fi + + echo '#!/usr/bin/env bash + +# Install additional composer dependencies as you would from the command line. +# echo "Installing Composer Dependencies" +# composer require tightenco/mailthief tightenco/quicksand + +# To copy standard files to new lambo project place them in ~/.lambo/includes directory. +# echo "Copying Include Files" +# cp -R ~/.lambo/includes/ $PROJECTPATH + +# To add a git commit after given modifications +# echo "Committing after modifications to Git" +# git add . +# git commit -am "Initialize Composer dependencies and additional files." +' > ~/.lambo/after + + edit ~/.lambo/after +} + edit() { ## Open with best editor @@ -137,6 +182,17 @@ if [[ $1 == "edit-config" ]]; then quit fi +### Check if user wants to set up a after file. +if [[ $1 == "make-after" ]]; then + makeafter + quit +fi + +if [[ $1 == "edit-after" ]]; then + editafter + quit +fi + ### Handle arguments while [[ $# -gt 0 ]]; do key="$1" @@ -273,6 +329,12 @@ case $PROJECTPATH in *) prettyPath="$PROJECTPATH/$PROJECTNAME" ;; esac +### Load after file if it exists +if [[ -f ~/.lambo/after ]]; then + echo "${green}Running additional commands...${reset}" + source ~/.lambo/after +fi + if [[ "$SHELL" != "" ]]; then exec "$SHELL" diff --git a/readme.md b/readme.md index f3c2a68d..e86f40a6 100644 --- a/readme.md +++ b/readme.md @@ -113,6 +113,18 @@ There are also a few optional behaviors based on the parameters you pass (or def lambo edit-config ``` +- `make-after` creates an "after" file so you can run additional commands after Lambo finishes + + ```bash + lambo make-after + ``` + +- `edit-after` edits your after file + + ```bash + lambo edit-after + ``` + ### Config You can create a config file at `~/.lambo/config` rather than pass the same arguments each time you create a new project. @@ -121,6 +133,31 @@ You can create a config file at `~/.lambo/config` rather than pass the same argu lambo make-config ``` +### After File + +You can create an after file at `~/.lambo/after` to run additional commands after you create a new project. + +```bash +lambo make-after +``` + +The after file is a bash script so you can include any commands here such as installing additional composer dependencies +``` +# Install additional composer dependencies as you would from the command line. +echo "Installing Composer Dependencies" +composer require tightenco/mailthief tightenco/quicksand +``` + +or copying additional files to your new project. + +```bash +# To copy standard files to new lambo project place them in ~/.lambo/includes directory. +echo "Copying Include Files" +cp -R ~/.lambo/includes/ $PROJECTPATH +``` + +You also have access to variables from your config file such as `$PROJECTPATH` and `$CODEEDITOR`. + ## Requirements - Mac or Ubuntu.