From 7741389fcfed2b0b921cc1cc09a8fad99df86ab8 Mon Sep 17 00:00:00 2001 From: Jeff Finley Date: Mon, 10 Jul 2017 22:13:55 -0700 Subject: [PATCH 1/3] Add support for after file Add a check for ~/.lambo/after and source it if it exists. Add make-after with boiler plate, and edit-after to match config options. Update Readme: Added make-after and edit-after to commands section. Added new section for After File with examples. --- lambo | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ readme.md | 37 ++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/lambo b/lambo index a95308cd..8a34a2c7 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,43 @@ 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 +' > ~/.lambo/after + + edit ~/.lambo/after +} + edit() { ## Open with best editor @@ -137,6 +177,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 +324,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..13a66f0c 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 a 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. From cd48f66b6ed220b1c66cb98b3eb2c15abe1ca213 Mon Sep 17 00:00:00 2001 From: Jeff Finley Date: Tue, 11 Jul 2017 10:35:09 -0700 Subject: [PATCH 2/3] Fix indentation and grammer --- lambo | 4 ++-- readme.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lambo b/lambo index 8a34a2c7..fc8741bc 100755 --- a/lambo +++ b/lambo @@ -21,8 +21,8 @@ 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 "${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" diff --git a/readme.md b/readme.md index 13a66f0c..e86f40a6 100644 --- a/readme.md +++ b/readme.md @@ -113,7 +113,7 @@ There are also a few optional behaviors based on the parameters you pass (or def lambo edit-config ``` -- `make-after` creates a after file so you can run additional commands after Lambo finishes +- `make-after` creates an "after" file so you can run additional commands after Lambo finishes ```bash lambo make-after From 89fce226c4abf8aae4cf51f3faa55a51b35bd05a Mon Sep 17 00:00:00 2001 From: Matt Stauffer Date: Tue, 11 Jul 2017 15:30:49 -0400 Subject: [PATCH 3/3] Update defaults for after file --- lambo | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lambo b/lambo index fc8741bc..ffaf3099 100755 --- a/lambo +++ b/lambo @@ -106,6 +106,11 @@ makeafter() # 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