From ddfb491fc1b368387f65f18536948012105cea5f Mon Sep 17 00:00:00 2001 From: Drew Robinson Date: Fri, 27 Nov 2026 22:20:32 +1100 Subject: [PATCH 1/4] docs: simpler, friendlier wording across the site Rewrites the guides in plainer language and trims repeated sections. Reference pages keep their detail, with sentence-case headings, fixed related links, and a Security page in the sidebar. Claude-Session: https://claude.ai/code/session_01LR8MxN9PGA7d5eovGNvam6 --- astro.config.mjs | 23 +-- src/content/docs/guides/command-execution.mdx | 118 +++++------- src/content/docs/guides/environment.mdx | 79 ++++---- src/content/docs/guides/getting-started.mdx | 66 +++---- src/content/docs/guides/importing.mdx | 43 +++-- src/content/docs/guides/next-steps.mdx | 48 ++--- .../docs/guides/shell-autocompletion.mdx | 64 ++++--- src/content/docs/guides/writing-commands.mdx | 112 ++++-------- src/content/docs/index.mdx | 63 +++---- src/content/docs/reference/cli.mdx | 47 +++-- src/content/docs/reference/environment.mdx | 41 ++--- src/content/docs/reference/yaml-schema.mdx | 171 +++++++----------- src/content/docs/security.mdx | 28 +++ 13 files changed, 398 insertions(+), 505 deletions(-) create mode 100644 src/content/docs/security.mdx 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..41417f0 100644 --- a/src/content/docs/guides/command-execution.mdx +++ b/src/content/docs/guides/command-execution.mdx @@ -1,24 +1,24 @@ --- -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 folder, then in each parent folder +3. Changes to the folder 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. +So a command behaves the same whichever subfolder you run it from. ## Arguments -Arguments are passed to commands as bash positional parameters: +Arguments arrive as bash positional parameters: ```yaml commands: @@ -38,10 +38,9 @@ ahoy copy src.txt dest.txt 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. +`"$@"` passes every argument through. `$#` is the number of arguments and `$0` is 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. Output also appears as it's produced, not all at once when the command finishes. -### Full-screen and TUI commands +### Full-screen tools -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,17 @@ 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. -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 +131,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 +160,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 folder 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..134d750 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 folder 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 +## Several 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 `➖`. -## 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..c6f7bb2 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. - +Output is not buffered either - a long-running command's output appears as it +is produced, not in a burst when the command exits. + ## Custom entrypoints By default Ahoy runs each command with `bash -c '{{cmd}}'`. Set `entrypoint` at the top of the file to use a different interpreter: @@ -163,6 +166,6 @@ commands: ## Troubleshooting - 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 folder or set variables in your shell. +- 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 134d750..c1a58f0 100644 --- a/src/content/docs/guides/environment.mdx +++ b/src/content/docs/guides/environment.mdx @@ -30,7 +30,7 @@ commands: cmd: mysql -u$DB_USER -p$DB_PASS $DB_NAME ``` -The path is relative to `.ahoy.yml`, not to the folder you're in. +The path is relative to `.ahoy.yml`, not to the directory you're in. ## For every command, or just one @@ -48,7 +48,7 @@ commands: cmd: ./deploy.sh ``` -## Several files +## Multiple files Either `env` can be a list. Files load in order, and later files override earlier ones: diff --git a/src/content/docs/guides/getting-started.mdx b/src/content/docs/guides/getting-started.mdx index c6f7bb2..86a769c 100644 --- a/src/content/docs/guides/getting-started.mdx +++ b/src/content/docs/guides/getting-started.mdx @@ -58,7 +58,7 @@ cd my-project ahoy config init ``` -This creates an `.ahoy.yml` in the current folder. Run `ahoy` on its own to see what's in it: +This creates an `.ahoy.yml` in the current directory. Run `ahoy` on its own to see what's in it: ```bash ahoy @@ -99,7 +99,7 @@ ahoy logs web ahoy # Lists all commands with their usage text ``` -Ahoy looks for `.ahoy.yml` in the current folder and then each parent folder, so these work from anywhere inside the 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 diff --git a/src/content/docs/guides/importing.mdx b/src/content/docs/guides/importing.mdx index 2f12cbf..75ce245 100644 --- a/src/content/docs/guides/importing.mdx +++ b/src/content/docs/guides/importing.mdx @@ -41,7 +41,7 @@ Now you have `ahoy db backup` and `ahoy db restore`. Every imported file needs its own `ahoyapi: v2` line. ## Optional imports diff --git a/src/content/docs/guides/shell-autocompletion.mdx b/src/content/docs/guides/shell-autocompletion.mdx index b916cea..e5b0c9b 100644 --- a/src/content/docs/guides/shell-autocompletion.mdx +++ b/src/content/docs/guides/shell-autocompletion.mdx @@ -50,6 +50,6 @@ Then open a new terminal, type `ahoy ` (with a space) and press Tab. Open a new terminal, type `ahoy ` and press Tab. You should see your commands and their aliases. diff --git a/src/content/docs/index.mdx b/src/content/docs/index.mdx index 634afd1..0eae830 100644 --- a/src/content/docs/index.mdx +++ b/src/content/docs/index.mdx @@ -45,8 +45,8 @@ Ahoy is a single binary. It works with Docker, SSH, local scripts, or anything e Run `ahoy` to list every command with its description. - - Ahoy finds your `.ahoy.yml` and always runs commands from the folder it's in. + + Ahoy finds your `.ahoy.yml` and always runs commands from the directory it's in. Long Docker and docker-compose commands become short names that are easy to remember.