Skip to content

Commit

Permalink
Issue #47: Update all examples, test files, and the README to reflect…
Browse files Browse the repository at this point in the history
… move from {{args}} to $@. (docs folder NOT done).
  • Loading branch information
Frank Carey committed Jan 22, 2017
1 parent b660399 commit c0d8481
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 19 deletions.
33 changes: 24 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Test Status: master [![CircleCI](https://circleci.com/gh/ahoy-cli/ahoy/tree/master.svg?style=svg)](https://circleci.com/gh/ahoy-cli/ahoy/tree/master)

Ahoy is command line tool that gives each of your projects their own CLI app with with zero code and dependencies.
Ahoy is command line tool that gives each of your projects their own CLI app with with zero code and dependencies.

Simply write your commands in a yaml file and ahoy gives you lots of features like:
* a command listing
Expand All @@ -29,7 +29,6 @@ With ahoy, you can turn this into
- Consitent - Commands always run relative to the .ahoy.yml file, but can be called from any subfolder.
- Visual - See a list of all of your commands in one place, along with helpful descriptions.
- Flexible - Commands are specific to a single folder tree, so each repo/workspace can have its own commands
- Command Templates - Args can be dropped into your commands using `{{args}}`
- Fully interactive - your shells (like mysql) and prompts still work.
- Self-Documenting - Commands and help declared in .ahoy.yml show up as ahoy command help and bash completion of commands (see below)

Expand Down Expand Up @@ -122,36 +121,52 @@ GLOBAL OPTIONS:

## Version 2

All new features are being added to the v2 (master) branch of ahoy which is still in alpha and will have breaking changes with v1 ahoy files, so to use ahoy v2, you'll need to do the following:
All new features are being added to the v2 (master) branch of ahoy which is still in alpha and will have breaking changes with v1 ahoy files, so to use ahoy v2, you'll need to do the following:
- Upgrade to the ahoy v2 binary which currently needs to be compiled from source. If you are using homebrew, you can use that to upgrade to v2 using the following:
```
brew uninstall ahoy # Required or you'll get errors
brew uninstall ahoy # Required or you'll get errors
brew upgrade # Updates the tap
brew install ahoy --HEAD # Installs ahoy by compiling the latest from the master branch
ahoy # You should see full version that you're using.
```
- Change your `ahoyapi: v1` lines to `ahoyapi: v2`
- Change your `{{args}}` items to the default bash symbol `"$@"`

### New Features in v2
- Implements a new feature to import mulitple config files using the "imports" field.
- Uses the "last in wins" rule to deal with duplicate commands amongst the config files.

```
- Better handling of quotes by no longer using `{{args}}`. Use regular bash syntax like `"$@"` for all arguments, or `$1` for the first argument.
- You can now use a different entrypoint (the thing that runs your commands) instead of bash. Ex. using php, nodejs, python, etc.
- Plugins are now possible by overriding the entrypoint.

###Example of new yaml setup in v2

```Yaml
# All files must have v2 set or you'll get an error
ahoyapi: v2

# You can now override the entrypoint. This is the default if you don't override it.
# {{cmd}} is replaced with your command and {{name}} is the name of the command that was run (available as $0)
entrypoint:
- bash
- "-c"
- '{{cmd}}'
- '{{name}}'
commands:
list:
usage: List the commands from the imported config files.
# These commands will be aggregated together with later files overriding earlier ones if they exist.
imports:
- ./confirmation.ahoy.yml
- ./docker.ahoy.yml
- ./examples.ahoy.yml
```
### Planned v2 features
- Provide "drivers" or "plugins" for bash, docker-compose, kubernetes (these systems still work now, this would just make it easier)
- Do specific arg replacement like {{arg1}} and enable specifying specific arguments and flags in the ahoy file itself to cut down on parsing arguments in scripts.
- Enable specifying specific arguments and flags in the ahoy file itself to cut down on parsing arguments in scripts.
- Support for more built-in commands or a "verify" yaml option that would create a yes / no prompt for potentially destructive commands. (Are you sure you want to delete all your containers?)
- Pipe tab completion to another command (allows you to get tab completion)

- Support for configuration
## Previewing the Read the Docs documentation locally.
Expand Down
2 changes: 1 addition & 1 deletion examples/confirmation.ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ahoyapi: v2
commands:
confirm:
cmd: |
read -r -p "{{args}} [y/N] " response
read -r -p "$@ [y/N] " response
if [ $response = y ]
then
true
Expand Down
2 changes: 1 addition & 1 deletion examples/docker.ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ commands:
cmd: "docker-compose stop && docker-compose rm && ahoy up"
usage: Start the docker compose-containers.
exec:
cmd: docker exec -it $(docker-compose ps -q cli) bash -c '{{args}}'
cmd: docker exec -it $(docker-compose ps -q cli) bash -c "$@"
usage: run a command in the docker-compose cli service container.
mysql:
cmd: "docker exec -it $(docker-compose ps -q cli) bash -c 'mysql -u$DB_ENV_MYSQL_USER -p$DB_ENV_MYSQL_PASSWORD -h$DB_PORT_3306_TCP_ADDR $DB_ENV_MYSQL_DATABASE'"
Expand Down
14 changes: 7 additions & 7 deletions examples/examples.ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@ commands:
usage: Stop the vagrant box if one exists.

ps:
cmd: "docker-compose ps {{args}}"
cmd: docker-compose ps "$@"
usage: List the running docker-compose containers.

start:
cmd: "docker-compose start {{args}}"
cmd: docker-compose start "$@"
usage: Start the docker compose-containers.

stop:
cmd: "docker-compose stop {{args}}"
cmd: docker-compose stop "$@"
usage: Stop the docker-compose containers.

restart:
cmd: "docker-compose restart {{args}}"
cmd: docker-compose restart "$@"
usage: Restart the docker-compose containers.

drush:
cmd: "docker-compose run cli drush --root=docroot {{args}}"
cmd: docker-compose run cli drush --root=docroot "$@"
usage: Run drush commands in the cli service container.

bash:
cmd: "docker-compose run {{args}} bash"
cmd: docker-compose run "$1" bash
usage: Start a shell in the container (like ssh without actual ssh).

sqlc:
cmd: "docker-compose run cli drush --root=docroot sqlc"
usage: Connect to the default mysql database. Supports piping of data into the command.

behat:
cmd: 'docker-compose run cli bash -c "cd docroot/test && composer install --prefer-source --no-interaction && bin/behat -p docker {{args}}"'
cmd: docker-compose run cli bash -c "cd docroot/test && composer install --prefer-source --no-interaction && bin/behat -p docker $@"
usage: Run the behat tests within the container.

behat-init:
Expand Down
2 changes: 1 addition & 1 deletion testdata/docker.ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ commands:
cmd: "docker-compose stop && docker-compose rm && ahoy up"
usage: Start the docker compose-containers.
exec:
cmd: docker exec -it $(docker-compose ps -q cli) bash -c '{{args}}'
cmd: docker exec -it $(docker-compose ps -q cli) bash -c "$@"
usage: run a command in the docker-compose cli service container.
mysql:
cmd: "docker exec -it $(docker-compose ps -q cli) bash -c 'mysql -u$DB_ENV_MYSQL_USER -p$DB_ENV_MYSQL_PASSWORD -h$DB_PORT_3306_TCP_ADDR $DB_ENV_MYSQL_DATABASE'"
Expand Down

0 comments on commit c0d8481

Please sign in to comment.