CLI reference
Synopsis
Section titled “Synopsis”ahoy [flags] [command] [args...]Global flags
Section titled “Global flags”Global flags belong before the command name. Everything after the command name belongs to that command - see Passing arguments to commands.
| Flag | Short | Description |
|---|---|---|
--file <path> |
-f |
Use a specific config file instead of searching for .ahoy.yml |
--verbose |
-v |
Enable verbose output |
--version |
Print the Ahoy version and exit | |
--help |
-h |
Show help |
ahoy --verbose deploy # --verbose is Ahoy'sahoy deploy --verbose # --verbose is passed to the deploy commandBuilt-in commands
Section titled “Built-in commands”ahoy config v3
Section titled “ahoy config ”Commands for setting up and checking your .ahoy.yml.
ahoy config init [url]
Section titled “ahoy config init [url]”Downloads a starter .ahoy.yml into the current directory. Without a URL it fetches the official examples file, which has around 30 commands. Pass a URL to download your own template instead.
ahoy config init # Download official examplesahoy config init https://... # Download a custom templateahoy config init --force # Overwrite an existing .ahoy.ymlahoy config validate
Section titled “ahoy config validate”Checks your .ahoy.yml and any imported files for:
- Unsupported or missing fields
- Missing import files (not marked
optional: true) - Features that require a newer version of Ahoy
ahoy config validateErrors are always shown. Warnings are only shown with --verbose. Where it can, the validator suggests a fix.
ahoy help
Section titled “ahoy help”ahoy help # Root help listingahoy help <command> # Help for a specific commandDeprecated: ahoy init
Section titled “Deprecated: ahoy init”ahoy init still works, but prints a notice and runs ahoy config init. Use ahoy config init in new scripts and docs.
Conventional commands
Section titled “Conventional commands”ahoy confirm <message>
Section titled “ahoy confirm <message>”confirm isn’t built in. It’s a small command you add to your own config, or import from confirmation.ahoy.yml, to ask before destructive operations. Other commands call it like a function.
It prompts with your message and exits 0 when the answer is y, or 1 otherwise, so it chains with &&, || and || exit 0:
ahoy confirm "Are you sure you want to do this?"# >> Are you sure you want to do this? [y/N]
ahoy confirm "Delete the build directory?" && rm -rf ./build || echo "Skipping..."A minimal definition:
commands: confirm: hide: true cmd: | read -r -p ">> $1 [y/N] " response [ "$response" = "y" ]hide: true keeps the helper out of the command listing without disabling it.
The examples file has a fuller version that also works in scripts and CI. Two environment variables control it:
| Variable | Effect |
|---|---|
AHOY_CONFIRM_RESPONSE |
Answers the prompt instead of reading from the terminal (e.g. y) |
AHOY_CONFIRM_WAIT_SKIP |
Set to 1 to skip the 3-second grace pause in automated mode |
AHOY_CONFIRM_RESPONSE=y AHOY_CONFIRM_WAIT_SKIP=1 ahoy db:resetOnly y or yes counts as yes. Writing commands shows the full version.
Config file discovery
Section titled “Config file discovery”Ahoy looks for its config file in this order:
- The file specified by
--file/-f .ahoy.ymlin the current directory.ahoy.ymlin each parent directory, up to the filesystem root
Commands run from the directory that contains the config file.
Passing arguments to commands
Section titled “Passing arguments to commands”Arguments after the command name are passed through as bash positional parameters:
ahoy greet World # $1 = "World"ahoy copy a.txt b.txt # $1 = "a.txt", $2 = "b.txt"ahoy run npm test # $@ = "npm test"Everything after the command name is passed through unchanged and in order, including anything that looks like a flag. Ahoy never takes a flag from there, even one of its own, so you can wrap other tools without surprises:
ahoy test --filter=MyTest --stop-on-failure # all four tokens reach the commandahoy fix-perms chown -R www-data:www-data . # -R is not Ahoy's to takeahoy phpunit --help # PHPUnit's help, not Ahoy'sTo reach Ahoy’s own help for a command, use ahoy help <command>.
A -- straight after the command name is allowed for readability and removed.
Any later -- is passed to the command, for tools that use a separator of
their own:
ahoy run -- npm test # $@ = "npm test"ahoy k exec mypod -- ls /app # $@ = "exec mypod -- ls /app"ahoy git checkout -- src/main.go # $@ = "checkout -- src/main.go"Where each token goes
Section titled “Where each token goes”| Typed | Read by | Reaches the command as |
|---|---|---|
ahoy --verbose test |
Ahoy | - |
ahoy -f build.yml test |
Ahoy | - |
ahoy -f=build.yml test |
Ahoy | - |
ahoy test --verbose |
Command | --verbose |
ahoy test --filter=X |
Command | --filter=X |
ahoy test -R -p /tmp/logs |
Command | -R -p /tmp/logs |
ahoy test --help |
Command | --help |
ahoy test -- --anything |
Command | --anything |
ahoy test a -- b |
Command | a -- b |
ahoy help test |
Ahoy | - |
Standard streams
Section titled “Standard streams”Each command uses the same stdin, stdout and stderr as the process that ran Ahoy, whether those are a terminal, pipes or files. From v3.0.1, Ahoy does not read, buffer, tee or copy them, so:
- Interactive commands get a real prompt and readline support when stdin is attached to a TTY
- Full-screen and TUI commands (
gum,fzf, anything on Bubble Tea) can query the terminal size and draw correctly when the relevant streams are a TTY - Output appears as it is produced rather than when the command exits
- Redirection behaves as it would without Ahoy -
ahoy test 2>errors.logsends the command’s stderr to the file, unbuffered, while stdout stays on the terminal
Ahoy v3.0.0 piped stderr, which broke full-screen tools. See Command execution.
Shell completion
Section titled “Shell completion”# Generate and install the completion scriptmkdir -p ~/.bash_completion.dahoy --generate-bash-completion > ~/.bash_completion.d/ahoyecho '. ~/.bash_completion.d/ahoy' >> ~/.bashrcsource ~/.bashrcUse the dedicated plugin at ahoy-cli/zsh-ahoy. See the Shell Autocompletion guide for setup instructions.
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
0 |
Success |
1 |
General error (command failed, config not found, etc.) |
If your command fails, Ahoy exits with 1, whatever exit code the command returned.
Environment variables set by Ahoy v3
Section titled “Environment variables set by Ahoy ”Ahoy adds these variables to every command’s environment:
| Variable | Value |
|---|---|
AHOY_COMMAND_NAME |
The name of the command being run |
AHOY_CMD |
Path to the ahoy binary |
Any script run through Ahoy can read them.