Skip to content

feat(hooks): add hooks command to list configured lifecycle hooks#515

Open
jongio wants to merge 1 commit into
mainfrom
idea/hooks
Open

feat(hooks): add hooks command to list configured lifecycle hooks#515
jongio wants to merge 1 commit into
mainfrom
idea/hooks

Conversation

@jongio

@jongio jongio commented Jul 13, 2026

Copy link
Copy Markdown
Owner

What

Adds azd app hooks, a read-only command that lists the project-level lifecycle hooks configured in azure.yaml.

For each configured hook (prerun, postrun, prestop, poststop) it shows the command it runs, the shell it uses, whether it continues on error or needs user interaction, and any per-platform override for Windows or POSIX.

Why

Lifecycle hooks run around azd app run and azd app stop, but there is no way to see what they are without opening azure.yaml and reading the nested hook blocks by hand. This lists them in lifecycle order so you can confirm what will run and spot a misconfigured shell or platform override quickly.

Usage

# List configured hooks
azd app hooks

# JSON array of hooks
azd app hooks --output json

Text output:

prerun
  run: ./setup.sh
  shell: (default)
  windows: setup.ps1 (shell: pwsh)
postrun
  run: ./cleanup.sh
  shell: bash

Details

  • Reuses the nil-safe Hooks accessors (GetPrerun, GetPostrun, GetPrestop, GetPoststop) so an absent hooks block is handled without special cases.
  • Hooks are listed in lifecycle order (prerun, postrun, prestop, poststop); unconfigured hooks are omitted.
  • Windows and POSIX overrides are rendered on their own line with the override command and shell.
  • JSON mode prints an array of hooks for programmatic use.
  • When no hooks are configured, the command prints a short message and exits zero.

Tests

Table-driven unit tests cover the empty case, lifecycle ordering and field mapping, platform overrides (including a pointer override left unset), the nil override path, JSON shape, and the small formatting helpers.

Verification

  • go build ./... clean
  • go vet ./src/cmd/app/commands/... clean
  • go test ./src/cmd/app/commands/ clean
  • golangci-lint run ./src/cmd/app/commands/... reports 0 issues

Closes #510

Add `azd app hooks` to list the project-level lifecycle hooks configured
in azure.yaml. For each hook (prerun, postrun, prestop, poststop) it shows
the command, shell, continueOnError and interactive flags, and any Windows
or POSIX override, in lifecycle order.

Reuses the nil-safe Hooks accessors so an absent hooks block needs no
special handling. Supports text and JSON output and prints a short message
when nothing is configured. Adds table-driven unit tests and docs.

Closes #510

Co-authored-by: Copilot App <[email protected]>
@jongio jongio added the idea Feature idea from the idea pipeline label Jul 13, 2026
@jongio jongio self-assigned this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

idea Feature idea from the idea pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add azd app hooks command to list configured lifecycle hooks

1 participant