Skip to content

Commit

Permalink
Merge branch 'quickliketurtle-jf-after-script'
Browse files Browse the repository at this point in the history
* quickliketurtle-jf-after-script:
  Update defaults for after file
  Fix indentation and grammer
  Add support for after file
  • Loading branch information
mattstauffer committed Jul 11, 2017
2 parents 082438f + 89fce22 commit 14e8fcd
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 0 deletions.
62 changes: 62 additions & 0 deletions lambo
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down
37 changes: 37 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 14e8fcd

Please sign in to comment.