Reduce Fig spec size by pruning help and output noise#8417
Conversation
0842295 to
9cc91b9
Compare
Co-authored-by: Copilot <copilot@github.com>
5f12aec to
1bb48cd
Compare
There was a problem hiding this comment.
Pull request overview
This PR reduces the size/noise of the generated Fig completion spec by (1) pruning the mirrored azd help <command> subtree by default and (2) removing redundant extension --output flag metadata/completions when it’s just the inherited default and not enriched with per-command output behavior.
Changes:
- Add
--include-help-subcommandsto optionally include the fullazd help <command>tree in the Fig spec; default output omits it. - Filter out the default inherited extension
--output/-oflag from generated extension metadata and from Fig completions unless the command has per-command output metadata (e.g., AllowedValues). - Update docs, snapshots, and tests to reflect the smaller spec and new flag behavior.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/pkg/azdext/metadata_generator.go | Skips emitting the default inherited extension --output flag when there’s no per-command override metadata. |
| cli/azd/pkg/azdext/metadata_generator_test.go | Updates expectations for filtered --output and adds a test ensuring version retains meaningful output metadata. |
| cli/azd/pkg/azdext/extension_commands.go | Registers --output allowed values (json) for the standard extension version command via RegisterFlagOptions. |
| cli/azd/internal/figspec/spec_builder.go | Adds WithHelpSubcommands and omits help subcommand mirroring by default when building the spec. |
| cli/azd/internal/figspec/figspec_coverage_test.go | Updates tests for help-subcommand behavior and adds coverage for extension-metadata error paths and global option generation. |
| cli/azd/internal/figspec/extension_metadata.go | Filters out default inherited extension --output options when converting extension metadata into Fig options. |
| cli/azd/internal/figspec/extension_metadata_test.go | Adds test coverage for the new extension --output filtering logic. |
| cli/azd/docs/fig-spec.md | Documents the new --include-help-subcommands flag and default help-tree pruning behavior. |
| cli/azd/cmd/testdata/TestUsage-azd-completion-fig.snap | Updates usage snapshot to include --include-help-subcommands. |
| cli/azd/cmd/testdata/TestFigSpec.ts | Updates the Fig spec snapshot to reflect reduced help tree and reduced --output noise. |
| cli/azd/cmd/completion.go | Wires the new --include-help-subcommands flag into Fig spec generation. |
| cli/azd/cmd/completion_test.go | Verifies the new flag is registered and defaults to false. |
Copilot's findings
- Files reviewed: 12/12 changed files
- Comments generated: 1
| if shouldSkipExtensionFlag(flag) { | ||
| continue | ||
| } |
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Fixes #8416
This PR reduces the generated Fig completion spec size by pruning low-value generated content. By default,
azd completion fignow emits only the top-levelazd helpcommand instead of duplicating the full command tree beneathhelp, while a new--include-help-subcommandsflag preserves the previous expanded output when needed.It also removes redundant inherited extension
--outputoptions from generated extension metadata and Fig completions when the command has not registered any command-specific output behavior. Commands that useRegisterFlagOptionsstill keep meaningful--outputmetadata, including allowed-value suggestions such asjson/tableand custom path-oriented usage text. The standard extensionversioncommand now explicitly registers its JSON output support so it continues to appear with useful completion suggestions.Validation
From
cli/azd/:go test ./internal/figspec ./pkg/azdext,go build,UPDATE_SNAPSHOTS=true go test ./cmd -run TestFigSpec, andgo test ./cmd -run 'TestCompletionFigFlags|TestCompletionFigAction_Run|TestFigSpec|TestUsage/azd/completion/fig$'.