diff --git a/astro.config.mjs b/astro.config.mjs
index a31c33a..2adb08d 100644
--- a/astro.config.mjs
+++ b/astro.config.mjs
@@ -24,12 +24,12 @@ export default defineConfig({
],
sidebar: [
{
- label: "Getting Started",
+ label: "Getting started",
items: [
- { label: "Installation & Setup", slug: "guides/getting-started" },
- { label: "Next Steps", slug: "guides/next-steps" },
+ { label: "Installation & setup", slug: "guides/getting-started" },
+ { label: "Next steps", slug: "guides/next-steps" },
{
- label: "Shell Autocompletion",
+ label: "Shell autocompletion",
slug: "guides/shell-autocompletion",
},
],
@@ -37,18 +37,19 @@ export default defineConfig({
{
label: "Guides",
items: [
- { label: "Writing Commands", slug: "guides/writing-commands" },
- { label: "Command Execution", slug: "guides/command-execution" },
- { label: "Importing & Overriding", slug: "guides/importing" },
- { label: "Environment", slug: "guides/environment" },
+ { label: "Writing commands", slug: "guides/writing-commands" },
+ { label: "Command execution", slug: "guides/command-execution" },
+ { label: "Importing & overriding", slug: "guides/importing" },
+ { label: "Environment variables", slug: "guides/environment" },
],
},
{
label: "Reference",
items: [
- { label: "CLI Reference", slug: "reference/cli" },
- { label: "Environment Reference", slug: "reference/environment" },
- { label: "YAML Schema", slug: "reference/yaml-schema" },
+ { label: "CLI reference", slug: "reference/cli" },
+ { label: "Environment reference", slug: "reference/environment" },
+ { label: "YAML schema", slug: "reference/yaml-schema" },
+ { label: "Security", slug: "security" },
],
},
],
diff --git a/src/content/docs/guides/command-execution.mdx b/src/content/docs/guides/command-execution.mdx
index 37ab0f7..8ff5c5f 100644
--- a/src/content/docs/guides/command-execution.mdx
+++ b/src/content/docs/guides/command-execution.mdx
@@ -1,18 +1,18 @@
---
-title: Command Execution
+title: Command execution
description: How Ahoy finds and runs your commands
---
import { Aside } from "@astrojs/starlight/components";
-## How Ahoy finds your config
+## Finding your config
-When you run an Ahoy command, it:
+When you run a command, Ahoy:
-1. Checks for a `--file` (or `-f`) flag to use a specific config file
-2. Otherwise, searches upward from the current directory for `.ahoy.yml`
-3. Changes to the directory containing that file
-4. Executes your command relative to that directory
+1. Uses the file given with `--file` (or `-f`), if there is one
+2. Otherwise looks for `.ahoy.yml` in the current directory, then in each parent directory
+3. Changes to the directory that file is in
+4. Runs your command from there
This means you can run `ahoy` from any subdirectory in your project and it always behaves consistently.
@@ -40,8 +40,7 @@ ahoy run-in-container npm test
`$@` passes all arguments through, which is handy for wrapper commands. Use `$#` to check the argument count, and `$0` for the command name.
-Everything after the command name reaches your command verbatim, flags
-included, so wrapping a tool that takes its own options needs nothing special:
+Everything after the command name reaches your command unchanged, flags included, so wrapping a tool with its own options just works:
```yaml
commands:
@@ -53,14 +52,18 @@ commands:
ahoy phpunit --filter=MyTest --stop-on-failure
```
-Ahoy's own flags - `--verbose`, `--file` and friends - are only recognised
-before the command name, so they never collide with your command's options.
+Ahoy's own flags, such as `--verbose` and `--file`, only count when they come before the command name, so they can't clash with your command's options.
+
+Ahoy removes a `--` only when it comes straight after the command name. Any other `--` is passed to your command, which matters for tools that use their own separator:
+
+```bash
+ahoy k exec mypod -- ls /app # kubectl gets its --
+ahoy run npm test -- --watch # npm passes --watch to the test script
+```
## Interactive commands
-All three standard streams - stdin, stdout and stderr - are inherited from the
-process that invoked Ahoy. Ahoy does not read, buffer or copy them, so a command
-runs exactly as it would if you had typed it yourself:
+Commands use the same stdin, stdout and stderr as the terminal or script that ran Ahoy. Ahoy doesn't read, buffer or copy them, so a command behaves exactly as if you'd typed it yourself:
```yaml
commands:
@@ -73,18 +76,11 @@ commands:
cmd: mysql -u$DB_USER -p$DB_PASS $DB_NAME
```
-When you run these from a terminal, the inherited streams are attached to a
-TTY, so they run fully interactively - you get a real prompt, readline support,
-and piping all work as expected. Invoked from a script or CI job, where the
-streams are pipes or files instead, the command sees exactly what it would see
-there without Ahoy.
+From a terminal you get a real prompt, line editing and working pipes. From a script or CI job, the command sees the same pipes or files it would see without Ahoy.
-### Full-screen and TUI commands
+### Full-screen tools and TUI commands
-Because the streams are the inherited descriptors rather than a copy of them,
-commands can ask about them directly - whether they are a TTY at all, and if so
-the terminal size - and get a true answer. When Ahoy is run from a terminal that
-is what full-screen and menu-driven tools need in order to draw:
+Full-screen and menu tools need to ask the terminal how big it is. Because Ahoy hands over the real terminal, they get the right answer and draw properly:
```yaml
commands:
@@ -97,47 +93,20 @@ commands:
cmd: docker compose logs --tail=1000 | fzf --tac
```
-Tools built on [Bubble Tea](https://github.com/charmbracelet/bubbletea) - `gum`,
-`glow` and similar - draw on stderr specifically, as do progress bars, spinners
-and anything that repaints in place.
+This covers tools built on [Bubble Tea](https://github.com/charmbracelet/bubbletea) such as `gum` and `glow`, which draw on stderr, along with progress bars and spinners.
- Ahoy v3.0.0 routed stderr through an internal pipe. Bytes still reached your
- terminal, but the terminal itself was no longer on the other end, so these
- tools measured a 0x0 screen and drew nothing - or, with `gum` on Bubble Tea
- v2, crashed outright. If you are on v3.0.0 and an interactive command renders
- blank, upgrade. See [issue #180](https://github.com/ahoy-cli/ahoy/issues/180).
+ Ahoy v3.0.0 sent stderr through an internal pipe. These tools then saw a 0x0 screen and drew
+ nothing, and `gum` on Bubble Tea v2 crashed. If an interactive command shows a blank screen on
+ v3.0.0, upgrade. See [issue #180](https://github.com/ahoy-cli/ahoy/issues/180).
Output is not buffered either - a long-running command's output appears as it
is produced, not in a burst when the command exits.
-## Chaining commands
-
-You can call other Ahoy commands from within a command:
-
-```yaml
-commands:
- ci:
- usage: Run the full CI pipeline locally
- cmd: |
- ahoy install
- ahoy lint
- ahoy test
-
- install:
- cmd: npm install
-
- lint:
- cmd: npm run lint
-
- test:
- cmd: npm test
-```
-
## Custom entrypoints
-The default entrypoint is `bash -c '{{cmd}}'`. Override it at the file level to use a different interpreter:
+By default Ahoy runs each command with `bash -c '{{cmd}}'`. Set `entrypoint` at the top of the file to use a different interpreter:
```yaml
ahoyapi: v2
@@ -165,26 +134,24 @@ commands:
cmd: print("Hello from Python!")
```
-Entrypoint template variables:
+The entrypoint can use these placeholders:
-- `{{cmd}}` - replaced with the command body
-- `{{name}}` - replaced with the command name (also available as `$0`)
+- `{{cmd}}`: the command body
+- `{{name}}`: the command name (also available as `$0`)
## Exit codes
-Ahoy passes exit codes through unchanged. If a command exits non-zero, Ahoy exits non-zero. This works naturally with shell pipelines:
+Ahoy exits with your command's exit code, so you can chain commands in the shell:
```bash
ahoy test && ahoy deploy
```
-## Controlling execution within a command
-
-Because the command body is bash, the usual operators control what runs next:
+Inside a command, the usual bash operators decide what runs next:
-- `&&` - run the next command only if the previous one succeeded (exit `0`)
-- `||` - run the next command only if the previous one failed (non-zero exit)
-- `;` - always run the next command
+- `&&` runs the next command only if the previous one succeeded
+- `||` runs the next command only if the previous one failed
+- `;` always runs the next command
```yaml
commands:
@@ -196,9 +163,9 @@ commands:
echo "4 - Do this no matter what"
```
-## Debugging and gotchas
+## Troubleshooting
-- **Use `--verbose` to see what actually ran.** It prints the resolved command before executing it, which is the fastest way to diagnose an unexpected result.
-- **Commands run in a subshell.** Environment variables are copied in, but nothing a command does can change your parent shell - it cannot change your current directory or set variables for your session.
-- **Quotes can be tricky.** When passing a command through to a subcommand, quotes can be lost along the way. Check `--verbose` first, then experiment with single versus double quotes. Prefer `cmd: |` for anything complex so YAML quoting stays out of the way.
-- **Check your YAML if Ahoy complains.** Indentation and structure errors surface as parse failures; `ahoy config validate` reports them along with unsupported fields.
+- Run with `--verbose` (before the command name) to see the exact command Ahoy ran.
+- Commands run in a subshell. They get a copy of your environment, but can't change your current directory or set variables in your shell.
+- Quotes can get lost when one command passes arguments to another. Check `--verbose` first, then try swapping single and double quotes. Using `cmd: |` for anything complicated keeps YAML quoting out of the way.
+- If Ahoy can't read your file, run `ahoy config validate`. It reports YAML mistakes and fields Ahoy doesn't support.
diff --git a/src/content/docs/guides/environment.mdx b/src/content/docs/guides/environment.mdx
index eea85ad..c1a58f0 100644
--- a/src/content/docs/guides/environment.mdx
+++ b/src/content/docs/guides/environment.mdx
@@ -1,15 +1,15 @@
---
-title: Environment Variables
-description: Loading environment files and managing configuration in Ahoy
+title: Environment variables
+description: Load environment files into your Ahoy commands
---
import { Aside, Badge } from "@astrojs/starlight/components";
-Ahoy can load environment variables from files before running your commands, keeping configuration and secrets out of your YAML.
+Ahoy can load variables from `.env` files before it runs a command, so settings and secrets stay out of your `.ahoy.yml`.
## A simple example
-Create a `.env` file alongside your `.ahoy.yml`:
+Create a `.env` file next to your `.ahoy.yml`:
```bash
DB_USER=root
@@ -17,7 +17,7 @@ DB_PASS=secret
DB_NAME=myapp
```
-Reference it in your config:
+Point to it in your config:
```yaml
ahoyapi: v2
@@ -30,11 +30,11 @@ commands:
cmd: mysql -u$DB_USER -p$DB_PASS $DB_NAME
```
-The path is relative to the `.ahoy.yml` file, not your working directory.
+The path is relative to `.ahoy.yml`, not to the directory you're in.
-## Global and per-command files
+## For every command, or just one
-The top-level `env` applies to every command. Individual commands can also specify their own `env`, which layers on top:
+An `env` at the top of the file applies to every command. A command can have its own `env` as well, which is loaded after the top-level one:
```yaml
ahoyapi: v2
@@ -44,13 +44,13 @@ env: .env # Loaded for every command
commands:
deploy:
usage: Deploy the application
- env: .env.deploy # Also loaded for this command only
+ env: .env.deploy # Also loaded, for this command only
cmd: ./deploy.sh
```
## Multiple files
-Both global and per-command `env` fields accept an array. Files are loaded in order - later files override earlier ones:
+Either `env` can be a list. Files load in order, and later files override earlier ones:
```yaml
ahoyapi: v2
@@ -67,70 +67,53 @@ commands:
cmd: ./deploy.sh staging
```
-A file like `.env.local` is often absent, for example when you start a project
-from a checked-out repo with an `.ahoy.yml` file in it. From v3.0.1 Ahoy
-reports this, rather than passing over it in silence, so please start marking such entries
-as optional - see below.
+## Files that might not exist
-## Files that may be absent
-
-A missing env file never stops a command - it is skipped, the variables it
-would have set stay empty, and the command runs. What changed in v3.0.1 is
-that Ahoy now shows a warning:
+If an env file is missing, Ahoy still runs the command. From v3.0.1 it also prints a warning, so a typo in a filename doesn't leave you wondering why a variable is empty:
```
[warn] environment file '.env.local' not found, continuing without it. Add 'optional: true' to that entry if it is meant to be absent.
```
-Every entry is required by default, so a typo in a filename surfaces instead of
-leaving you to work out why a variable is empty. For the files that are meant
-to be missing - a personal `.env.local` that only some developers have - write
-the entry as a mapping and mark it `optional: true`:
+Some files are meant to be missing, such as a personal `.env.local` that only some people have. Mark those `optional: true` and Ahoy won't warn about them:
```yaml
env:
- - .env.base # Required: warns when absent
+ - .env.base # Warns if missing
- path: .env.local
- optional: true # Silent when absent
+ optional: true # Quiet if missing
```
-This is the same `optional` you may already use on
-[imports](/guides/importing/): simply meaning that the file is not expected to
-always present.
-
-The warning goes to stderr, so it never contaminates a command's stdout when
-you pipe it. `ahoy config validate` distinguishes the two as well, listing a
-missing required file with `❌` and a missing optional one with `➖ ... -
-missing, marked optional`.
+This works like `optional` on [imports](/guides/importing/). The warning goes to stderr, so it won't end up in piped output. `ahoy config validate` lists a missing required file with `❌` and a missing optional one with `➖`.
- The mapping form is not understood by earlier versions - Ahoy v2.5.0 fails to
- parse it with `cannot unmarshal !!seq into string`. Keep the plain string form
- if your `.ahoy.yml` is shared with anyone still on v2 or v3.0.0.
+ Older versions can't read the `path`/`optional` form. Ahoy v2.5.0 fails with
+ `cannot unmarshal !!seq into string`. Stick to plain filenames if anyone using your `.ahoy.yml` is
+ on v2 or v3.0.0.
-## Precedence
+## Which value wins
-From lowest to highest:
+If the same variable is set in more than one place, the later one wins:
-1. Your shell's existing environment
-2. Global env files (in order)
-3. Command-specific env files (in order)
+1. Your shell's environment
+2. Top-level env files, in order
+3. The command's own env files, in order
-## Runtime variables
+## Variables Ahoy sets
-Ahoy automatically injects two variables into every command:
+Ahoy adds two variables to every command:
| Variable | Value |
| ------------------- | --------------------------------- |
| `AHOY_COMMAND_NAME` | The name of the command being run |
| `AHOY_CMD` | Path to the ahoy binary |
-These are useful for scripts that call other ahoy commands, or need to know their own name.
+Use them in scripts that call other Ahoy commands or need to know their own name.
-## Keep secrets out of version control
+## Keep secrets out of git
-Add your real `.env` files to `.gitignore` and commit a `.env.example` with placeholder values:
+Add your real `.env` files to `.gitignore`, and commit a `.env.example` with placeholder values instead:
```
# .gitignore
@@ -146,4 +129,4 @@ DB_PASS=your_password
DB_NAME=your_database
```
-For the complete format specification and precedence details, see the [Environment Reference](/reference/environment).
+The [Environment reference](/reference/environment) has the full file format.
diff --git a/src/content/docs/guides/getting-started.mdx b/src/content/docs/guides/getting-started.mdx
index c141960..86a769c 100644
--- a/src/content/docs/guides/getting-started.mdx
+++ b/src/content/docs/guides/getting-started.mdx
@@ -1,12 +1,12 @@
---
-title: Getting Started with Ahoy
+title: Getting started with Ahoy
description: Install Ahoy and run your first commands
---
import { Tabs, TabItem } from "@astrojs/starlight/components";
import { Aside } from "@astrojs/starlight/components";
-## Installation
+## Install
@@ -19,57 +19,54 @@ import { Aside } from "@astrojs/starlight/components";
os=$(uname -s | tr '[:upper:]' '[:lower:]') && architecture=$(case $(uname -m) in (x86_64 | amd64) echo "amd64" ;; (aarch64 | arm64 | armv8*) echo "arm64" ;; (armv7*) echo "armv7" ;; (armv6*) echo "armv6" ;; esac) && { [ -n "$architecture" ] || { echo "Unsupported architecture: $(uname -m)" >&2; false; }; } && sudo wget -q https://github.com/ahoy-cli/ahoy/releases/latest/download/ahoy-bin-$os-$architecture -O /usr/local/bin/ahoy && sudo chown $USER /usr/local/bin/ahoy && chmod +x /usr/local/bin/ahoy
```
- Or download the [latest release from GitHub](https://github.com/ahoy-cli/ahoy/releases) and place the binary somewhere in your `$PATH`.
+ Or download the [latest release from GitHub](https://github.com/ahoy-cli/ahoy/releases) and put the binary somewhere in your `$PATH`.
- Use the Linux instructions above.
+ Use the Linux instructions.
-
- Homebrew has switched to v3, so `brew install ahoy` now installs the latest v3 release. The Linux
- command above resolves to v3 as well, since it downloads from `/releases/latest/`.
+Check it works:
- v3 is intended to be fully backwards compatible with existing v2 `.ahoy.yml` files, so most
- projects need no changes. If you do still need v2, download it from the
- [v2.5.0 release page](https://github.com/ahoy-cli/ahoy/releases/tag/v2.5.0) - v2.5.0 is the latest
- v2 release, and there is no `ahoy@2` Homebrew formula.
+```bash
+ahoy --version
+```
+
+We recommend you [verify your download](#verifying-your-download) too.
+
+
+ Both commands above install v3. It reads v2 `.ahoy.yml` files, so most projects need no changes.
+
+ If you still need v2, the last release is
+ [v2.5.0](https://github.com/ahoy-cli/ahoy/releases/tag/v2.5.0). There's no `ahoy@2` Homebrew
+ formula, so download it directly:
```bash
- # Linux amd64. The v2 release also provides ahoy-bin-linux-arm64, ahoy-bin-linux-arm,
+ # Linux amd64. The release also has ahoy-bin-linux-arm64, ahoy-bin-linux-arm,
# ahoy-bin-darwin-amd64 and ahoy-bin-darwin-arm64.
sudo wget -q https://github.com/ahoy-cli/ahoy/releases/download/v2.5.0/ahoy-bin-linux-amd64 -O /usr/local/bin/ahoy && sudo chown $USER /usr/local/bin/ahoy && chmod +x /usr/local/bin/ahoy
```
-For security's sake, please [verify your download](#verifying-your-download).
+## Start with the examples
-Then verify that `ahoy` is working:
-
-```bash
-ahoy --version
-```
-
-## Start with examples
-
-The quickest way to get going is to initialise a project with our curated examples file. It includes 20+ ready-to-use commands for common development workflows.
+The fastest way in is the examples file, which has around 30 commands for common development jobs:
```bash
cd my-project
ahoy config init
```
-This creates an `.ahoy.yml` in the current directory. Run `ahoy` on its own to see what's available:
+This creates an `.ahoy.yml` in the current directory. Run `ahoy` on its own to see what's in it:
```bash
ahoy
```
- Want to inspect the file before downloading? The examples file is at
- [`examples/examples.ahoy.yml`](https://github.com/ahoy-cli/ahoy/blob/master/examples/examples.ahoy.yml)
- in the repository.
+ You can read the file first on GitHub:
+ [`examples/examples.ahoy.yml`](https://github.com/ahoy-cli/ahoy/blob/master/examples/examples.ahoy.yml).
## Write your own commands
@@ -93,19 +90,16 @@ commands:
cmd: docker-compose logs -f "$@"
```
-Run your commands from anywhere in the project tree:
+Then run them:
```bash
ahoy hello World # Hello, World!
ahoy start
ahoy logs web
-ahoy # Shows all commands and their usage text
+ahoy # Lists all commands with their usage text
```
-
- Ahoy searches up the directory tree for `.ahoy.yml`, so you can run commands from any subdirectory
- in your project.
-
+Ahoy looks for `.ahoy.yml` in the current directory and then each parent directory, so these work from anywhere inside the project.
## Verifying your download
@@ -165,7 +159,7 @@ In v3.0.0 and earlier, the checksums file only lists the `.tar.gz` and `.zip` ar
## Next steps
-- [Writing Commands](/guides/writing-commands) - practical patterns and real-world examples
-- [Shell Autocompletion](/guides/shell-autocompletion) - set up tab completion
-- [YAML Schema Reference](/reference/yaml-schema) - complete field-by-field reference
-- [CLI Reference](/reference/cli) - all command-line flags and built-in commands
+- [Writing commands](/guides/writing-commands): arguments, aliases and longer scripts
+- [Shell autocompletion](/guides/shell-autocompletion): set up tab completion
+- [YAML schema](/reference/yaml-schema): every field in `.ahoy.yml`
+- [CLI reference](/reference/cli): flags and built-in commands
diff --git a/src/content/docs/guides/importing.mdx b/src/content/docs/guides/importing.mdx
index 444f6df..75ce245 100644
--- a/src/content/docs/guides/importing.mdx
+++ b/src/content/docs/guides/importing.mdx
@@ -1,15 +1,15 @@
---
-title: Importing & Overriding
-description: Splitting commands across multiple files and overriding inherited commands
+title: Importing & overriding
+description: Split commands across several files and override imported commands
---
import { Aside, Badge } from "@astrojs/starlight/components";
-As your command set grows, you can split it across multiple YAML files using `imports`.
+When your `.ahoy.yml` gets long, you can move groups of commands into other files with `imports`.
-## Basic imports
+## Importing a file
-A command with `imports` instead of `cmd` becomes a namespace for subcommands loaded from other files:
+Give a command `imports` instead of `cmd`, and the commands in those files become its subcommands:
```yaml
# .ahoy.yml
@@ -28,7 +28,7 @@ ahoyapi: v2
commands:
backup:
- usage: Backup the database
+ usage: Back up the database
cmd: mysqldump -u$DB_USER -p$DB_PASS $DB_NAME > backup.sql
restore:
@@ -36,11 +36,17 @@ commands:
cmd: mysql -u$DB_USER -p$DB_PASS $DB_NAME < $1
```
-This gives you `ahoy db backup` and `ahoy db restore`.
+Now you have `ahoy db backup` and `ahoy db restore`.
+
+Every imported file needs its own `ahoyapi: v2` line.
+
+
+ Import paths are relative to the file that contains them, not to the directory you're in.
+
## Optional imports
-Mark an import as `optional: true` to silently skip the whole command if none of its files can be found. Useful for local or team-specific command sets that not everyone has:
+Normally Ahoy stops with an error if an imported file is missing. Add `optional: true` and Ahoy skips the command quietly instead. This suits personal or team-only commands that not everyone has:
```yaml
ahoyapi: v2
@@ -53,11 +59,11 @@ commands:
- ./local.ahoy.yml
```
-If `local.ahoy.yml` doesn't exist, `ahoy local` simply won't appear in the listing. Without `optional: true`, a missing import file is a fatal error.
+If `local.ahoy.yml` doesn't exist, `ahoy local` just doesn't appear in the list.
## Overriding commands
-Ahoy uses a "last in wins" rule. When the same command name appears in multiple imported files, the last definition wins:
+When two commands have the same name, the last one defined wins:
```yaml
# .ahoy/base.ahoy.yml
@@ -83,11 +89,11 @@ commands:
cmd: npm test -- --coverage
```
-The top-level `test` command overrides the imported one.
+Here the `test` in `.ahoy.yml` replaces the imported one.
-## Typical structure
+## A typical layout
-A common pattern for larger projects:
+Larger projects often keep one file per topic:
```
project/
@@ -119,14 +125,9 @@ commands:
- ./.ahoy/deploy.ahoy.yml
```
-
- Import paths are relative to the directory containing the file that declares them, not your
- working directory.
-
+## Sharing commands between projects
-## Sharing commands across projects
-
-Import paths can traverse outside the project directory, which makes it possible to maintain shared command libraries:
+Import paths can point outside the project, so several projects can share one set of commands:
```yaml
commands:
@@ -134,5 +135,3 @@ commands:
imports:
- ../../shared-ahoy/docker.ahoy.yml
```
-
-Each imported file must also declare `ahoyapi: v2`.
diff --git a/src/content/docs/guides/next-steps.mdx b/src/content/docs/guides/next-steps.mdx
index 538c543..724f540 100644
--- a/src/content/docs/guides/next-steps.mdx
+++ b/src/content/docs/guides/next-steps.mdx
@@ -1,42 +1,42 @@
---
-title: Next Steps
-description: What to explore after the basics
+title: Next steps
+description: Where to go after the basics
sidebar:
order: 2
---
import { Card, CardGrid } from "@astrojs/starlight/components";
-You've got Ahoy installed and your first commands running. Here's where to go next.
+Once Ahoy is installed and running your first commands, these pages cover the rest.
## Guides
-
- Practical patterns for arguments, aliases, multi-line scripts, chaining, and real-world examples.
+
+ Arguments, aliases, multi-line scripts and wrapping other tools.
- [Writing Commands →](/guides/writing-commands)
+ [Writing commands](/guides/writing-commands)
-
- Understand how Ahoy finds your config, passes arguments, handles interactive commands, and supports custom entrypoints.
+
+ How Ahoy finds your config, passes arguments and runs interactive tools.
- [Command Execution →](/guides/command-execution)
+ [Command execution](/guides/command-execution)
-
- Split commands across multiple YAML files and use the override system to adapt shared command sets.
+
+ Split commands across several files and replace commands you've imported.
- [Importing & Overriding →](/guides/importing)
+ [Importing & overriding](/guides/importing)
-
- Load `.env` files globally or per-command, stack multiple files, and manage configuration across environments.
+
+ Load `.env` files for every command or just one.
- [Environment →](/guides/environment)
+ [Environment variables](/guides/environment)
@@ -45,24 +45,24 @@ You've got Ahoy installed and your first commands running. Here's where to go ne
## Reference
-
- Complete technical reference for every field supported in `.ahoy.yml`.
+
+ Every field you can use in `.ahoy.yml`.
- [YAML Schema →](/reference/yaml-schema)
+ [YAML schema](/reference/yaml-schema)
-
- All command-line flags, built-in commands, and config file discovery rules.
+
+ Flags, built-in commands and how Ahoy finds your config file.
- [CLI Reference →](/reference/cli)
+ [CLI reference](/reference/cli)
-
- Full specification for the environment file format, variable precedence, and Ahoy's runtime variables.
+
+ The env file format, which values win, and the variables Ahoy sets.
- [Environment Reference →](/reference/environment)
+ [Environment reference](/reference/environment)
diff --git a/src/content/docs/guides/shell-autocompletion.mdx b/src/content/docs/guides/shell-autocompletion.mdx
index f1815c0..e5b0c9b 100644
--- a/src/content/docs/guides/shell-autocompletion.mdx
+++ b/src/content/docs/guides/shell-autocompletion.mdx
@@ -1,57 +1,55 @@
---
-title: Shell Autocompletion
+title: Shell autocompletion
description: Set up tab completion for Ahoy commands
---
import { Tabs, TabItem } from "@astrojs/starlight/components";
import { Aside } from "@astrojs/starlight/components";
-Ahoy supports tab completion in both Zsh and Bash, completing command names and aliases from your `.ahoy.yml`.
+Ahoy can tab-complete command names and aliases from your `.ahoy.yml` in Zsh and Bash.
## Zsh
-There's a dedicated plugin at [ahoy-cli/zsh-ahoy](https://github.com/ahoy-cli/zsh-ahoy) that works with all major Zsh plugin managers.
+Install the [ahoy-cli/zsh-ahoy](https://github.com/ahoy-cli/zsh-ahoy) plugin. Its README has instructions for Oh My Zsh, Antigen, zinit and manual installs.
-1. Visit the [ahoy-cli/zsh-ahoy](https://github.com/ahoy-cli/zsh-ahoy) repository and follow the installation instructions for your plugin manager (Oh My Zsh, Antigen, zinit, or manual).
-2. Reload your shell or open a new terminal.
-3. Type `ahoy ` (with a space) and press Tab - you should see your commands listed.
+Then open a new terminal, type `ahoy ` (with a space) and press Tab.
## Bash
-**Step 1:** Make sure bash-completion is installed:
+1. Install bash-completion:
-
-
- ```bash
- brew install bash-completion
- ```
-
-
- ```bash
- sudo apt install bash-completion
- ```
-
-
+
+
+ ```bash
+ brew install bash-completion
+ ```
+
+
+ ```bash
+ sudo apt install bash-completion
+ ```
+
+
-**Step 2:** Generate the completion script and install it:
+2. Generate the completion script and load it from your `.bashrc`:
-```bash
-mkdir -p ~/.bash_completion.d
-ahoy --generate-bash-completion > ~/.bash_completion.d/ahoy
-echo '. ~/.bash_completion.d/ahoy' >> ~/.bashrc
-```
+ ```bash
+ mkdir -p ~/.bash_completion.d
+ ahoy --generate-bash-completion > ~/.bash_completion.d/ahoy
+ echo '. ~/.bash_completion.d/ahoy' >> ~/.bashrc
+ ```
-**Step 3:** Reload your configuration:
+3. Reload your config:
-```bash
-source ~/.bashrc
-```
+ ```bash
+ source ~/.bashrc
+ ```
-## Testing your setup
+## Check it works
-Open a new terminal, type `ahoy ` and press Tab. You should see a list of your available commands. Aliases are completed alongside primary command names.
+Open a new terminal, type `ahoy ` and press Tab. You should see your commands and their aliases.
- Completion only shows commands available in the current context. Make sure you're inside a project
- with an `.ahoy.yml` file (or one of its subdirectories) to see project commands.
+ You'll only see project commands when you're inside a directory that has an `.ahoy.yml`, or inside
+ one of its subdirectories.
diff --git a/src/content/docs/guides/writing-commands.mdx b/src/content/docs/guides/writing-commands.mdx
index 82fc290..6863b44 100644
--- a/src/content/docs/guides/writing-commands.mdx
+++ b/src/content/docs/guides/writing-commands.mdx
@@ -1,15 +1,15 @@
---
-title: Writing Commands
-description: Practical patterns for writing great Ahoy commands
+title: Writing commands
+description: Patterns for writing Ahoy commands your team will use
---
import { Aside, Badge } from "@astrojs/starlight/components";
-Ahoy commands are shell commands wrapped in YAML. This guide covers the patterns that make them readable, reusable, and a pleasure for your whole team to use.
+An Ahoy command is a shell command with a name and some help text, written in YAML.
## A minimal command
-Every command needs a name and a `cmd`. Everything else is optional but encouraged:
+A command needs a name and a `cmd`. Everything else is optional, but a `usage` line is worth adding:
```yaml
ahoyapi: v2
@@ -20,11 +20,11 @@ commands:
cmd: echo "Hello, $1!"
```
-The `usage` line is what your team sees when they run `ahoy` - make it count.
+The `usage` line is what people see when they run `ahoy`, so keep it short and clear.
## Arguments
-Arguments are passed through as standard bash positional parameters:
+Arguments arrive as normal bash positional parameters. Use `$1`, `$2` and so on for specific ones, or `"$@"` to pass them all through:
```yaml
commands:
@@ -32,47 +32,27 @@ commands:
usage: Open a shell in a container
cmd: docker compose exec $1 bash
- copy:
- usage: Copy a file between containers
- cmd: docker compose cp $1 $2
-
run:
usage: Run any command in the app container
cmd: docker compose exec app "$@"
```
-`$1`, `$2` for specific positions; `$@` to forward everything. The last pattern is great for transparent wrappers:
-
-```bash
-ahoy run npm test -- --watch
-```
-
-Flags count as arguments. Everything after the command name reaches your
-command exactly as typed, in order, and Ahoy never claims any of it:
-
```bash
+ahoy shell web
ahoy run npm test --watch
ahoy run chown -R www-data:www-data .
```
-Ahoy consumes a `--` only when it is the first thing after the command name,
-where it has always just meant "the rest is arguments". A `--` anywhere else
-belongs to your command, so wrapping a tool that needs its own separator works
-as you would expect:
-
-```bash
-ahoy k exec mypod -- ls /app # kubectl gets its separator
-ahoy run npm test -- --watch # npm passes --watch to the test script
-```
+Flags count as arguments. Everything you type after the command name reaches your command as typed, in the same order. [Command execution](/guides/command-execution#arguments) has the details, including how `--` is handled.
## Multi-line scripts
-Use the YAML block scalar (`|`) for anything beyond a single line. Standard bash applies:
+For anything longer than one line, use a YAML block (`|`). It's normal bash inside:
```yaml
commands:
setup:
- usage: Initialise the project from scratch
+ usage: Set up the project from scratch
cmd: |
echo "Installing dependencies..."
npm install
@@ -83,30 +63,30 @@ commands:
echo "All done. Run 'ahoy start' to begin."
```
-## Descriptions for complex commands
+## Longer help text
-`usage` is the one-liner shown in the listing. `description` is fuller help shown when someone runs `ahoy help `:
+`usage` is the one line shown in the list. `description` is longer help, shown when someone runs `ahoy help `:
```yaml
commands:
deploy:
usage: Deploy the application
description: |
- Deploys to the specified environment, running tests and building
- assets first. Requires .env.deploy to be configured.
+ Deploys to the given environment, running tests and building
+ assets first. Needs .env.deploy to be set up.
Usage:
ahoy deploy staging
ahoy deploy production
- The production deploy will prompt for confirmation unless CI=true
- is set in the environment.
+ The production deploy asks for confirmation unless CI=true
+ is set.
cmd: ./scripts/deploy.sh $1
```
-## Aliases
+## Aliases
-Short names for commonly-used commands. They appear in the help listing alongside the primary name:
+Aliases are short names for a command. They're listed next to the main name:
```yaml
commands:
@@ -121,11 +101,11 @@ commands:
cmd: docker compose exec app bash
```
-A good rule of thumb: use a descriptive primary name and short aliases for the commands you type dozens of times a day.
+Give the command a descriptive name, and add short aliases for the ones you type all day.
-## Chaining commands
+## Calling other commands
-Call other Ahoy commands from within a command - Ahoy is always on the path:
+A command can run other Ahoy commands:
```yaml
commands:
@@ -145,9 +125,9 @@ commands:
ahoy install
```
-## Protecting destructive operations
+## Asking before destructive commands
-A `confirm` helper is a useful pattern for commands that can't be undone. The [examples file](https://github.com/ahoy-cli/ahoy/blob/master/examples/examples.ahoy.yml) includes a battle-tested implementation that supports both interactive use and automation (via `AHOY_CONFIRM_RESPONSE=y`):
+For commands that can't be undone, add a `confirm` helper that asks first. The [examples file](https://github.com/ahoy-cli/ahoy/blob/master/examples/examples.ahoy.yml) has one that also works in scripts and CI, where you answer in advance with `AHOY_CONFIRM_RESPONSE=y`:
```yaml
commands:
@@ -175,11 +155,11 @@ commands:
fi
```
-The `hide: true` field keeps internal helpers out of the listing without disabling them.
+`hide: true` keeps a helper out of the command list. You can still run it.
-## Wrapper commands
+## Wrapping other tools
-Ahoy is excellent for wrapping long container commands so they feel native:
+Ahoy works well for wrapping long container commands:
```yaml
commands:
@@ -196,10 +176,7 @@ commands:
cmd: docker compose exec app node "$@"
```
-Then your team just runs `ahoy drush cache:rebuild` or `ahoy composer require vendor/package`.
-
-The wrapped tool keeps its own flags, including the ones that would otherwise
-be Ahoy's:
+Now the team can run `ahoy drush cache:rebuild` or `ahoy composer require vendor/package`. The wrapped tool gets all its own flags, even ones Ahoy also uses:
```bash
ahoy drush --help # Drush's help
@@ -208,21 +185,17 @@ ahoy drush sql:query --extra=-A "SELECT 1"
ahoy node --version
```
-The one thing to know: since `--help` belongs to the wrapped tool, Ahoy's own
-help for a command is `ahoy help drush`.
+Because `--help` goes to the wrapped tool, use `ahoy help drush` to see Ahoy's help for the command.
- Ahoy v3.0.0 parsed a command's arguments before running it and silently
- dropped any flag it did not recognise, along with the token following it -
- so `ahoy fix-perms chown -R www-data:www-data .` arrived as `chown .`. The
- wrapped tool ran successfully with different arguments, which made this
- quiet rather than loud. Upgrade if you wrap anything that takes flags. See
- [issue #182](https://github.com/ahoy-cli/ahoy/issues/182).
+ Ahoy v3.0.0 dropped any flag it didn't recognise, along with the word after it, without telling
+ you. So `ahoy fix-perms chown -R www-data:www-data .` ran as `chown .`. Upgrade if you wrap
+ anything that takes flags. See [issue #182](https://github.com/ahoy-cli/ahoy/issues/182).
-## Environment-specific commands
+## Commands with their own env file
-Use the `env` field for commands that need their own configuration:
+Use `env` to load settings for one command:
```yaml
commands:
@@ -234,19 +207,14 @@ commands:
rsync -avz ./dist/ $DEPLOY_HOST:$DEPLOY_PATH
```
-See the [Environment guide](/guides/environment) for the full picture on env files and precedence.
-
-## Real-world examples
+The [Environment variables guide](/guides/environment) covers env files in full.
-The repository includes ready-to-use example files you can copy and adapt:
+## Example files
-- **[examples.ahoy.yml](https://github.com/ahoy-cli/ahoy/blob/master/examples/examples.ahoy.yml)** - the comprehensive starter file (30+ commands covering Docker, databases, testing, Drupal, deployment, and more). Download it with `ahoy config init`.
-- **[docker.ahoy.yml](https://github.com/ahoy-cli/ahoy/blob/master/examples/docker.ahoy.yml)** - a focused set of Docker Compose commands, useful as an import in your own config.
-- **[confirmation.ahoy.yml](https://github.com/ahoy-cli/ahoy/blob/master/examples/confirmation.ahoy.yml)** - a standalone confirmation helper you can import.
+The repository has example files you can copy:
-
- The best way to learn is to read `examples.ahoy.yml` - it demonstrates nearly every Ahoy feature
- with real, usable commands. Run `ahoy config init` to drop it into your project.
-
+- [examples.ahoy.yml](https://github.com/ahoy-cli/ahoy/blob/master/examples/examples.ahoy.yml): around 30 commands for Docker, databases, testing, Drupal and deployment. `ahoy config init` downloads it, and it uses nearly every Ahoy feature, so it's a good file to read.
+- [docker.ahoy.yml](https://github.com/ahoy-cli/ahoy/blob/master/examples/docker.ahoy.yml): Docker Compose commands to import into your own config.
+- [confirmation.ahoy.yml](https://github.com/ahoy-cli/ahoy/blob/master/examples/confirmation.ahoy.yml): the confirmation helper on its own, ready to import.
-For the complete field-by-field specification, see the [YAML Schema reference](/reference/yaml-schema).
+Every field is listed in the [YAML schema](/reference/yaml-schema).
diff --git a/src/content/docs/index.mdx b/src/content/docs/index.mdx
index 0f80d14..0eae830 100644
--- a/src/content/docs/index.mdx
+++ b/src/content/docs/index.mdx
@@ -3,11 +3,11 @@ title: Welcome to Ahoy
description: Create self-documenting CLI programs from YAML files
template: doc
hero:
- tagline: Give every project its own CLI - zero code, zero dependencies, just YAML.
+ tagline: Give each project its own command-line tool, written in a YAML file.
image:
file: ../../assets/ahoy-hero.webp
actions:
- - text: Get Started
+ - text: Get started
link: /guides/getting-started
icon: right-arrow
variant: primary
@@ -18,41 +18,38 @@ hero:
import { Card, CardGrid } from "@astrojs/starlight/components";
-## What is Ahoy?
+## About Ahoy
-Ahoy is a command-line tool that turns your project's scripts and commands into a self-documenting CLI. You write a `.ahoy.yml` file, and Ahoy gives your whole team a consistent, discoverable interface to run things - from any project subdirectory, with tab completion and help text built in.
+Ahoy turns the commands you run on a project into short, named commands that everyone on the team can use. You list them in an `.ahoy.yml` file, and Ahoy runs them from anywhere in the project, with help text and tab completion included.
-It turns something like this:
+So instead of typing this:
```bash
docker-compose exec --user=82 web drush cache:rebuild --uri=https://example.com
```
-Into this:
+you type this:
```bash
ahoy cr
```
-No programming required. No dependencies to install. It works with Docker, SSH, local scripts, or anything you can run from a shell.
+Ahoy is a single binary. It works with Docker, SSH, local scripts, or anything else you can run from a shell.
-## Why use Ahoy?
+## Why use it
-
- Write some YAML and you're done. Commands are defined once and work the same way for everyone on
- the team.
+
+ Write a command once and it works the same way for everyone on the team.
- Running `ahoy` lists all available commands with their descriptions. Your README doesn't need a
- commands section anymore.
+ Run `ahoy` to list every command with its description.
-
- Run commands from any subdirectory - Ahoy finds the config and always executes relative to it.
+
+ Ahoy finds your `.ahoy.yml` and always runs commands from the directory it's in.
-
- Turn verbose Docker and docker-compose commands into short, memorable aliases your whole team
- can use.
+
+ Long Docker and docker-compose commands become short names that are easy to remember.
@@ -62,7 +59,7 @@ No programming required. No dependencies to install. It works with Docker, SSH,
# Install (macOS)
brew install ahoy
-# Initialise a project with example commands
+# Add an .ahoy.yml full of example commands
cd my-project
ahoy config init
@@ -70,35 +67,35 @@ ahoy config init
ahoy
```
-The examples file includes 30+ ready-to-use commands for environment management, testing, databases, and Drupal. Customise it or start fresh - either way, you're up and running in minutes.
+The examples file has around 30 commands for Docker, testing, databases and Drupal. Keep the ones you want and delete the rest.
-[Get Started →](/guides/getting-started)
+[Get started](/guides/getting-started)
## Explore
-
- Practical patterns for arguments, aliases, multi-line scripts, chaining, and real-world examples.
+
+ Arguments, aliases, multi-line scripts and wrapping other tools.
- [Writing Commands →](/guides/writing-commands)
+ [Writing commands](/guides/writing-commands)
-
- Split commands across multiple files and build reusable command libraries.
+
+ Split commands across several files and share them between projects.
- [Importing & Overriding →](/guides/importing)
+ [Importing & overriding](/guides/importing)
-
- Load `.env` files per-command or globally, and manage configuration across environments safely.
+
+ Load `.env` files for every command or just one.
- [Environment →](/guides/environment)
+ [Environment variables](/guides/environment)
-
- Complete technical reference for every field in `.ahoy.yml`.
+
+ Every field you can use in `.ahoy.yml`.
- [YAML Schema →](/reference/yaml-schema)
+ [YAML schema](/reference/yaml-schema)
diff --git a/src/content/docs/reference/cli.mdx b/src/content/docs/reference/cli.mdx
index 9df431b..9b4ca6b 100644
--- a/src/content/docs/reference/cli.mdx
+++ b/src/content/docs/reference/cli.mdx
@@ -1,5 +1,5 @@
---
-title: CLI Reference
+title: CLI reference
description: Complete reference for Ahoy command-line options and built-in commands
---
@@ -33,11 +33,11 @@ ahoy deploy --verbose # --verbose is passed to the deploy command
### `ahoy config`
-Management commands for your Ahoy configuration.
+Commands for setting up and checking your `.ahoy.yml`.
#### `ahoy config init [url]`
-Downloads a starter `.ahoy.yml` into the current directory. Without a URL it fetches the official examples file (30+ ready-to-use commands). Pass a custom URL to download your own template.
+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.
```bash
ahoy config init # Download official examples
@@ -47,7 +47,7 @@ ahoy config init --force # Overwrite an existing .ahoy.yml
#### `ahoy config validate`
-Checks your `.ahoy.yml` (and any imported files) for common issues:
+Checks your `.ahoy.yml` and any imported files for:
- Unsupported or missing fields
- Missing import files (not marked `optional: true`)
@@ -57,7 +57,7 @@ Checks your `.ahoy.yml` (and any imported files) for common issues:
ahoy config validate
```
-Errors are always shown. Warnings are shown in verbose mode (`--verbose`). The validator also provides actionable suggestions when it finds a problem.
+Errors are always shown. Warnings are only shown with `--verbose`. Where it can, the validator suggests a fix.
### `ahoy help`
@@ -68,13 +68,13 @@ ahoy help # Help for a specific command
### Deprecated: `ahoy init`
-`ahoy init` still works but is deprecated. It redirects to `ahoy config init` with a notice. Prefer `ahoy config init` in any new scripts or documentation.
+`ahoy init` still works, but prints a notice and runs `ahoy config init`. Use `ahoy config init` in new scripts and docs.
## Conventional commands
### `ahoy confirm `
-`confirm` is not built in - it is a convention: a small command you define in your own config (and can import from [confirmation.ahoy.yml](https://github.com/ahoy-cli/ahoy/blob/master/examples/confirmation.ahoy.yml)) to guard destructive operations. Because Ahoy commands can call other Ahoy commands, it behaves like a reusable function.
+`confirm` isn't built in. It's a small command you add to your own config, or import from [confirmation.ahoy.yml](https://github.com/ahoy-cli/ahoy/blob/master/examples/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`:
@@ -98,7 +98,7 @@ commands:
`hide: true` keeps the helper out of the command listing without disabling it.
-The [examples file](https://github.com/ahoy-cli/ahoy/blob/master/examples/examples.ahoy.yml) carries a fuller version that also works unattended, controlled by two environment variables you set yourself:
+The [examples file](https://github.com/ahoy-cli/ahoy/blob/master/examples/examples.ahoy.yml) has a fuller version that also works in scripts and CI. Two environment variables control it:
| Variable | Effect |
| ----------------------- | ----------------------------------------------------------------- |
@@ -109,17 +109,17 @@ The [examples file](https://github.com/ahoy-cli/ahoy/blob/master/examples/exampl
AHOY_CONFIRM_RESPONSE=y AHOY_CONFIRM_WAIT_SKIP=1 ahoy db:reset
```
-See [Writing Commands](/guides/writing-commands) for the full pattern.
+[Writing commands](/guides/writing-commands#asking-before-destructive-commands) shows the full version.
## Config file discovery
-Ahoy searches for `.ahoy.yml` in the following order:
+Ahoy looks for its config file in this order:
1. The file specified by `--file` / `-f`
2. `.ahoy.yml` in the current directory
3. `.ahoy.yml` in each parent directory, up to the filesystem root
-The directory containing the found config file becomes the working directory for all commands.
+Commands run from the directory that contains the config file.
## Passing arguments to commands
@@ -131,10 +131,9 @@ 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 **verbatim and in order**,
-including anything that looks like a flag. Ahoy never claims a flag there, even
-one of its own - which is what makes Ahoy usable as a wrapper around other
-tools:
+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:
```bash
ahoy test --filter=MyTest --stop-on-failure # all four tokens reach the command
@@ -144,9 +143,9 @@ ahoy phpunit --help # PHPUnit's help, not Ahoy's
To reach Ahoy's own help for a command, use `ahoy help `.
-A leading `--` is accepted for readability and removed before the arguments are
-passed on. Any later `--` is the command's own data and reaches it untouched,
-which matters for the many tools that need a separator of their own:
+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:
```bash
ahoy run -- npm test # $@ = "npm test"
@@ -171,9 +170,9 @@ ahoy git checkout -- src/main.go # $@ = "checkout -- src/main.go"
## Standard streams
-Ahoy passes stdin, stdout and stderr through unchanged - each command inherits
-the streams of the process that invoked Ahoy, whether those are a terminal,
-pipes, or files. It does not read, buffer, tee or copy them, so:
+Each command uses the same stdin, stdout and stderr as the process that ran
+Ahoy, whether those are a terminal, pipes or files. 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
@@ -209,15 +208,15 @@ Use the dedicated plugin at [ahoy-cli/zsh-ahoy](https://github.com/ahoy-cli/zsh-
| `0` | Success |
| `1` | General error (command failed, config not found, etc.) |
-Ahoy passes the exit code of the underlying command through unchanged.
+Otherwise Ahoy exits with your command's own exit code.
## Environment variables set by Ahoy
-Ahoy injects the following variables into every command's environment:
+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 |
-These are available to any script invoked through Ahoy.
+Any script run through Ahoy can read them.
diff --git a/src/content/docs/reference/environment.mdx b/src/content/docs/reference/environment.mdx
index 7aadedf..2125204 100644
--- a/src/content/docs/reference/environment.mdx
+++ b/src/content/docs/reference/environment.mdx
@@ -1,5 +1,5 @@
---
-title: Environment Variables Reference
+title: Environment variables reference
description: Complete specification for environment file format, variable precedence, and Ahoy's runtime variables
---
@@ -7,15 +7,15 @@ import { Aside, Badge } from "@astrojs/starlight/components";
## Overview
-Ahoy can load environment variables from files before executing any command. Files are declared using the `env` field at the config level (global) or within individual commands (per-command). Both levels accept the same three forms:
+Ahoy can load environment variables from files before it runs a command. You list the files in an `env` field, either at the top of the config (global) or inside a command (per-command). Both accept the same forms:
- A single file path: `env: .env`
- An array of file paths
-- An array mixing file paths with `{ path, optional }` mapping entries , which mark the files that are allowed to be absent - see [Optional env files](#optional-env-files-)
+- An array mixing file paths with `{ path, optional }` mapping entries , for files that are allowed to be missing. See [Optional env files](#optional-env-files-)
## File path resolution
-All env file paths are relative to the directory containing the `.ahoy.yml` file - not your current working directory. This ensures consistent behaviour regardless of which subdirectory you run commands from.
+Env file paths are relative to the directory containing the `.ahoy.yml` file, not your current directory, so they resolve the same way from any subdirectory.
## Precedence
@@ -25,10 +25,10 @@ Variables are applied in this order, from lowest to highest priority:
2. **Global env files** - loaded in the order listed under the top-level `env` key
3. **Command-specific env files** - loaded in the order listed under a command's `env` key
-Later sources override earlier ones. A command-specific variable always wins over a global one with the same name.
+Later sources override earlier ones, so a command's own variable always beats a global one with the same name.
- A missing env file is skipped and the command still runs - specifying a file that doesn't exist is
+ A missing env file is skipped and the command still runs. Listing a file that doesn't exist is
not an error. From Ahoy reports the missing
file on stderr unless its entry is marked `optional: true`; see [Optional env
files](#optional-env-files-) below.
@@ -43,8 +43,8 @@ writes a warning to stderr and carries on:
[warn] environment file '.env.local' not found, continuing without it. Add 'optional: true' to that entry if it is meant to be absent.
```
-The command still runs, and the exit code is unchanged; only the reporting is new. Because the
-warning goes to stderr, a command's stdout stays clean for piping.
+The command still runs with the same exit code. The warning goes to stderr, so a command's stdout
+stays clean for piping.
To declare a file that is expected to be missing, write the entry as a mapping with `path` and
`optional`:
@@ -58,10 +58,9 @@ env:
optional: false # Same as the plain string form
```
-`optional` means the same thing here as it does for
-[`imports`](/reference/yaml-schema/): the entry may legitimately not resolve to a file. It is set on
-the env entry itself, though - the command-level `optional` flag covers imports only, and does not
-silence a missing env file.
+`optional` means the same here as it does for
+[`imports`](/reference/yaml-schema/#optional-): the file may not exist. It's set on each env entry,
+though. The command-level `optional` flag only covers imports and does not silence a missing env file.
The two forms mix freely within one list, and both work at the global and per-command level. Every
pre-v3.0.1 form parses unchanged: the `env: .env` shorthand, plain lists, empty lists and nulls.
@@ -82,7 +81,7 @@ pre-v3.0.1 form parses unchanged: the `env: .env` shorthand, plain lists, empty
## Runtime variables
-Ahoy automatically injects two variables into every command's environment, regardless of any `env` file configuration:
+Ahoy adds two variables to every command's environment, whatever your `env` files contain:
| Variable | Value |
| ------------------- | --------------------------------- |
@@ -93,7 +92,7 @@ These cannot be overridden by env files.
## File format specification
-Ahoy env files use standard shell variable format. The parser follows these rules:
+Env files use the usual shell variable format, with these rules:
- One variable per line: `NAME=VALUE`
- Lines starting with `#` are treated as comments and ignored
@@ -142,11 +141,11 @@ If you need these, set variables in a shell script and call that script from you
## Variable naming
-By convention, environment variable names use `UPPER_SNAKE_CASE`. Names can contain letters, digits, and underscores. Names starting with a digit are technically invalid in most shells.
+Names are usually `UPPER_SNAKE_CASE`. Use letters, digits and underscores, and don't start a name with a digit: most shells won't accept it.
## Security
-Never commit real credentials to version control. A common pattern:
+Don't commit real credentials to version control. A common setup:
```
project/
@@ -163,7 +162,7 @@ project/
*.secrets
```
-## Organisation patterns
+## Ways to organise env files
**By environment:**
@@ -182,7 +181,7 @@ project/
.env.deploy # Deployment configuration
```
-**Layered approach** (useful for team projects):
+**Layered** (handy for teams):
```yaml
env:
@@ -192,7 +191,7 @@ env:
## Accessing variables in commands
-Variables are available through standard shell syntax in `bash` commands:
+In `bash` commands, use normal shell syntax:
```yaml
commands:
@@ -201,7 +200,7 @@ commands:
cmd: mysql -u$DB_USER -p$DB_PASS -h$DB_HOST $DB_NAME
```
-Or with defaults using bash parameter expansion:
+Or give a default with bash parameter expansion:
```yaml
commands:
@@ -209,4 +208,4 @@ commands:
cmd: python -m http.server ${PORT:-8000}
```
-When using a non-bash entrypoint, access variables through the appropriate mechanism for that runtime (e.g. `process.env.VARIABLE` in Node.js, `os.environ['VARIABLE']` in Python).
+With a non-bash entrypoint, read variables the way that language does (e.g. `process.env.VARIABLE` in Node.js, `os.environ['VARIABLE']` in Python).
diff --git a/src/content/docs/reference/yaml-schema.mdx b/src/content/docs/reference/yaml-schema.mdx
index 4c93531..296b4de 100644
--- a/src/content/docs/reference/yaml-schema.mdx
+++ b/src/content/docs/reference/yaml-schema.mdx
@@ -5,22 +5,20 @@ description: Complete technical reference for the Ahoy YAML configuration schema
import { Aside, Badge } from "@astrojs/starlight/components";
-# YAML Schema Reference
+Every field Ahoy supports in its YAML config files, with types, defaults and validation rules. The **Implementation** lines name the Go function that handles each field, for anyone reading the source.
-This technical reference documents the complete schema for Ahoy YAML configuration files. It details all supported fields, validation rules, and implementation details as defined in the Ahoy codebase.
+## YAML file format
-## YAML File Format
+Ahoy reads commands and settings from a YAML file. By default it looks for `.ahoy.yml` in the current directory, then in each parent directory. Use `-f` to point at a different file.
-Ahoy uses YAML configuration files to define commands and settings. By default, Ahoy looks for a file named `.ahoy.yml` in the current directory or any parent directory. A custom file can be specified using the `-f` flag.
+## Schema structure
-## Schema Structure
-
-The Ahoy configuration schema consists of two main data structures:
+The schema has two parts:
1. **Config** - The top-level object containing global settings and commands
2. **Command** - Individual command definitions within the `commands` map
-## Top-Level Fields
+## Top-level fields
```yaml
# Required: API version declaration
@@ -46,13 +44,13 @@ commands:
cmd: command to run
```
-## Field Specifications
+## Field specifications
### `ahoyapi`
**Required**: Yes
**Type**: String
-**Allowed Values**: `v2`
+**Allowed values**: `v2`
**Default**: None
**Implementation**: Validated in `getConfig()` function
**Description**: Specifies the Ahoy API version to use. Currently only version `v2` is supported. This field is required in all Ahoy files including imported ones to ensure forward compatibility.
@@ -61,7 +59,7 @@ commands:
ahoyapi: v2
```
-**Validation Rule**: If this field is not set to `v2`, Ahoy will exit with an error.
+**Validation rule**: If this field is not set to `v2`, Ahoy will exit with an error.
### `usage`
@@ -69,7 +67,7 @@ ahoyapi: v2
**Type**: String
**Default**: `"Creates a configurable cli app for running commands."`
**Implementation**: Set in `setupApp()` function
-**Description**: Defines the usage description for the entire Ahoy application, displayed in help text.
+**Description**: A description of the whole command set, shown in Ahoy's help text.
```yaml
usage: "Collection of commands for the project"
@@ -81,9 +79,9 @@ usage: "Collection of commands for the project"
**Type**: String, Array of Strings, or Array of Strings and Mappings
**Default**: None
**Implementation**: Processed in `getCommands()` function
-**Description**: Path(s) to global environment file(s), relative to the YAML file location. Environment variables defined here are available to all commands in this configuration file. Supports both single file and multiple files syntax.
+**Description**: Path(s) to global environment file(s), relative to the YAML file location. Variables defined here are available to every command in this file. Takes a single path or a list.
-**Single Environment File (backwards compatible)**:
+**Single environment file (backwards compatible)**:
```yaml
env: .env
@@ -91,7 +89,7 @@ env: .env.local
env: ../shared/config.env
```
-**Multiple Environment Files** :
+**Multiple environment files** :
```yaml
env:
@@ -100,11 +98,11 @@ env:
- .env.override
```
-**Optional Environment Files** :
+**Optional environment files** :
An entry written as a mapping takes a `path` and an `optional` flag. Entries are required by
-default; a required file that is absent is reported on stderr, while an optional one is passed over
-without comment. Both forms may be mixed in the same list.
+default: a missing required file is reported on stderr, and a missing optional one is skipped
+quietly. You can mix both forms in one list.
```yaml
env:
@@ -113,15 +111,15 @@ env:
optional: true # Silent when absent
```
-**Technical Details**:
+**Technical details**:
- Environment variables are loaded at runtime and passed to command processes
- When using multiple files, they are loaded in order with later files overriding earlier ones
- Blank lines and lines starting with '#' are ignored
- Variables from global files can be overridden by command-specific environment files
- A non-existent file is skipped and the command still runs; from v3.0.1 it is reported on stderr
- unless that entry is marked `optional: true`. This is set per env entry, and is a different thing
- from the command-level [`optional`](#optional-) flag, which covers imports only
+ unless that entry is marked `optional: true`. This is set per env entry, and is separate from
+ the command-level [`optional`](#optional-) flag, which only covers imports
- Maintains full backwards compatibility with single file syntax
### `entrypoint`
@@ -130,7 +128,7 @@ env:
**Type**: Array of Strings
**Default**: `["bash", "-c", "{{cmd}}", "{{name}}"]`
**Implementation**: Default set in `getConfig()`, replacement in command action
-**Description**: Defines the command interpreter and arguments used to execute commands. The default uses bash.
+**Description**: The interpreter and arguments used to run each command. The default is bash.
```yaml
entrypoint:
@@ -140,12 +138,12 @@ entrypoint:
- "{{name}}"
```
-**Template Variables**:
+**Template variables**:
- `{{cmd}}`: Replaced with the command's `cmd` value
- `{{name}}`: Replaced with the command name
-**Implementation Details**:
+**Implementation details**:
- Template variables are replaced at runtime before execution
- The final command is executed with the working directory set to the directory containing the YAML file
@@ -156,13 +154,13 @@ entrypoint:
**Type**: Map of command definitions
**Default**: None
**Implementation**: Processed in `getCommands()` function
-**Description**: Container for all command definitions. Each key represents a command name, and its value is a command configuration object.
+**Description**: Holds all command definitions. Each key is a command name, and its value is that command's settings.
-**Validation Rule**: This field must be present and contain at least one command.
+**Validation rule**: This field must be present and contain at least one command.
-## Command Definition Fields
+## Command definition fields
-Each command defined under `commands` can have the following fields:
+Each command under `commands` can have these fields:
### `usage`
@@ -170,7 +168,7 @@ Each command defined under `commands` can have the following fields:
**Type**: String
**Default**: Empty
**Implementation**: Set in CLI command setup in `getCommands()`
-**Description**: Short help text shown when running `ahoy help command-name`. This appears as a brief summary in the command listing.
+**Description**: A one-line summary, shown in the command list and in `ahoy help command-name`.
```yaml
commands:
@@ -184,7 +182,7 @@ commands:
**Type**: String
**Default**: Empty
**Implementation**: Set in CLI command setup in `getCommands()`
-**Description**: Longer, detailed description shown when running `ahoy help command-name`. This is displayed below the usage text and supports multi-line content for comprehensive documentation.
+**Description**: Longer help shown by `ahoy help command-name`, below the usage text. It can span several lines.
```yaml
commands:
@@ -214,7 +212,7 @@ commands:
**Type**: String
**Default**: None
**Implementation**: Executed through the entrypoint in command action
-**Description**: The command to execute. Can be a single line or a multi-line command.
+**Description**: The command to run, on one line or several.
```yaml
commands:
@@ -228,7 +226,7 @@ commands:
echo "Done!"
```
-**Technical Details**:
+**Technical details**:
- Executed through the configured entrypoint (default is bash)
- Has access to environment variables from both global and command-specific env files
@@ -240,7 +238,7 @@ commands:
**Type**: Array of Strings
**Default**: Empty
**Implementation**: Set in CLI command setup in `getCommands()`
-**Description**: Alternative names for invoking the command. Each alias can be used interchangeably with the primary command name.
+**Description**: Other names that run the same command.
```yaml
commands:
@@ -267,13 +265,13 @@ commands:
- ./commands/docker.ahoy.yml
```
-**Validation Rules**:
+**Validation rules**:
- Cannot be used together with `cmd` (must specify one or the other)
- Must contain at least one item if specified
- If the imports don't resolve to valid files and `optional` is false, Ahoy will exit with an error
-**Implementation Details**:
+**Implementation details**:
- Relative paths are resolved based on the parent YAML file location
- Commands from the imported files become subcommands under this command
@@ -285,9 +283,9 @@ commands:
**Type**: String, Array of Strings, or Array of Strings and Mappings
**Default**: None
**Implementation**: Processed in command action
-**Description**: Path(s) to command-specific environment file(s), relative to the YAML file location. Variables defined here override any with the same name in the global env files. Supports both single file and multiple files syntax.
+**Description**: Path(s) to command-specific environment file(s), relative to the YAML file location. Variables defined here override any with the same name from the global env files. Takes a single path or a list.
-**Single Environment File (backwards compatible)**:
+**Single environment file (backwards compatible)**:
```yaml
commands:
@@ -297,7 +295,7 @@ commands:
cmd: ./deploy.sh
```
-**Multiple Environment Files** :
+**Multiple environment files** :
```yaml
commands:
@@ -310,7 +308,7 @@ commands:
cmd: ./deploy.sh
```
-**Optional Environment Files** :
+**Optional environment files** :
```yaml
commands:
@@ -323,13 +321,13 @@ commands:
cmd: ./deploy.sh
```
-**Technical Details**:
+**Technical details**:
- When using multiple files, they are loaded in order with later files overriding earlier ones
- Command-specific environment files always override global environment files
- A non-existent file is skipped and the command still runs; from v3.0.1 it is reported on stderr
- unless that entry is marked `optional: true`. This is set per env entry, and is a different thing
- from the command-level [`optional`](#optional-) flag, which covers imports only
+ unless that entry is marked `optional: true`. This is set per env entry, and is separate from
+ the command-level [`optional`](#optional-) flag, which only covers imports
- Maintains full backwards compatibility with single file syntax
### `hide`
@@ -338,7 +336,7 @@ commands:
**Type**: Boolean
**Default**: `false`
**Implementation**: Set in CLI command setup in `getCommands()`
-**Description**: When set to `true`, the command will not be shown in the help output, but can still be invoked.
+**Description**: When `true`, the command is left out of the help output but can still be run.
```yaml
commands:
@@ -354,7 +352,7 @@ commands:
**Type**: Boolean
**Default**: `false`
**Implementation**: Checked in `getCommands()` function
-**Description**: When set to `true`, prevents errors when a command's imported files are not found. Used primarily for optional command groups. It applies to `imports` and nothing else.
+**Description**: When `true`, a command whose imported files can't be found is skipped instead of causing an error. It applies to `imports` and nothing else.
```yaml
commands:
@@ -383,7 +381,7 @@ commands:
See [`env`](#env-) for the mapping form.
-## Complete Schema Example
+## Complete schema example
```yaml
ahoyapi: v2
@@ -439,37 +437,22 @@ commands:
echo "Done!"
```
-## Environment File Format
-
-Environment files use standard shell format:
-
-```bash
-# Comments are supported
-VARIABLE=value
-QUOTED="value with spaces"
+## Environment file format
-# Multi-line values
-CERT="-----BEGIN CERTIFICATE-----
-MIICWDCCAcGgAwIBAgIJAKe0yZE6xcJ2MA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV
-...
------END CERTIFICATE-----"
+See the [Environment variables reference](/reference/environment#file-format-specification).
-# Export is optional
-export PATH=$PATH:/usr/local/bin
-```
-
-## Command Execution Context
+## Command execution context
Commands have access to:
-### Positional Arguments
+### Positional arguments
- `$1`, `$2`, etc.: Individual arguments
- `$@`: All arguments as array
- `$#`: Number of arguments
- `$0`: Command name
-### Environment Variables
+### Environment variables
- Variables from the shell environment
- Variables from global env files
@@ -477,29 +460,31 @@ Commands have access to:
- `AHOY_COMMAND_NAME` - the name of the command being run (injected by Ahoy)
- `AHOY_CMD` - path to the ahoy binary (injected by Ahoy)
-## Special Considerations
+## Special considerations
-### File Paths
+### File paths
- All paths are relative to the YAML file location
- Environment file paths are also relative
- Import paths should use `./` for current directory
-### Command Override Rules
+### Command override rules
- Later commands override earlier ones
- Imported commands can be overridden
- Last definition wins
-### Environment Variable Precedence
+### Environment variable precedence
+
+Highest priority first:
-1. Command-specific env file
-2. Global env file
-3. System environment variables
+1. Command-specific env files
+2. Global env files
+3. Shell environment variables
-## Best Practices
+## Best practices
-### YAML File Organisation
+### YAML file organisation
```yaml
# Start with version
@@ -524,7 +509,7 @@ commands:
usage: ...
```
-### Command Naming
+### Command naming
```yaml
commands:
@@ -537,35 +522,13 @@ commands:
usage: Run database migrations
```
-### Usage Documentation
+### Usage text
-Use `usage` for brief descriptions and `description` for detailed documentation:
-
-```yaml
-commands:
- deploy:
- usage: Deploy the application to specified environment
- description: |
- Deploy the application to the specified environment with optional version.
-
- This command performs a complete deployment including:
- - Building the application
- - Running tests
- - Deploying to target environment
- - Sending notifications
-
- Arguments:
- $1: Environment (dev|staging|prod)
- $2: Version tag (optional)
-
- Examples:
- ahoy deploy dev v1.0.0
- ahoy deploy prod
-```
+Keep `usage` to one short line and put anything longer in `description`. See [`description`](#description) for an example.
-## Related Topics
+## Related topics
-- [Writing Commands](guides/writing-commands)
-- [Command Execution](guides/command-execution)
-- [Environment Variables](guides/environment)
-- [CLI Reference](reference/cli)
+- [Writing commands](/guides/writing-commands)
+- [Command execution](/guides/command-execution)
+- [Environment variables](/guides/environment)
+- [CLI reference](/reference/cli)
diff --git a/src/content/docs/security.mdx b/src/content/docs/security.mdx
new file mode 100644
index 0000000..5f97c71
--- /dev/null
+++ b/src/content/docs/security.mdx
@@ -0,0 +1,28 @@
+---
+title: Security
+description: How to report a security problem in Ahoy
+---
+
+## Reporting a vulnerability
+
+If you think you've found a security problem in Ahoy, please report it privately through GitHub's form rather than opening a public issue:
+
+[Report a vulnerability](https://github.com/ahoy-cli/ahoy/security/advisories/new)
+
+Only the maintainers can see your report. It helps to include:
+
+- the Ahoy version (`ahoy --version`) and your operating system
+- the steps or a minimal `.ahoy.yml` that shows the problem
+- what an attacker could do with it
+
+Ahoy is maintained by volunteers, so replies are best effort. We'll confirm we've received your report, keep you updated while we work on a fix, and credit you in the advisory unless you'd rather stay anonymous. Please give us 14 days to release a fix before you share details publicly.
+
+The full policy is in [SECURITY.md](https://github.com/ahoy-cli/ahoy/blob/master/SECURITY.md).
+
+## Supported versions
+
+Security fixes go into the latest v3 release. Upgrade to it before reporting, in case the problem is already fixed.
+
+## Verifying downloads
+
+Releases from v3.0.1 onwards include a SHA-256 checksum for every binary, and releases from v3.0.2 onwards are also signed with cosign. Older releases either have no checksums file or don't list the `ahoy-bin-*` binaries in it. See [Verifying your download](/guides/getting-started/#verifying-your-download).