Skip to content

Conversation

@feiskyer
Copy link
Member

This pull request introduces logic to ensure that all Azure CLI commands executed by our code default to JSON output unless an explicit output format is specified. This helps standardize command responses and makes downstream processing more predictable. The changes are implemented for both string-based and slice-based argument handling, with comprehensive unit tests added for each helper.

Output format enforcement:

  • Added the ensureOutputFormatArgs helper to internal/components/azaks/executor.go to append --output json to command-line arguments when no output format is specified, using shlex for robust argument parsing. [1] [2] [3]
  • Added the ensureOutputArg helper to internal/components/monitor/handlers.go for slice-based argument lists, ensuring --output json is present unless an output flag is already specified. [1] [2]

Testing:

  • Added unit tests for ensureOutputFormatArgs in internal/components/azaks/executor_test.go to cover various scenarios, including malformed input.
  • Added unit tests for ensureOutputArg in internal/components/monitor/handlers_test.go to verify correct behavior for different argument combinations.

Copy link
Member

@gossion gossion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gossion gossion added this pull request to the merge queue Sep 25, 2025
Merged via the queue into main with commit eef6d82 Sep 25, 2025
9 checks passed
@gossion gossion deleted the tool-json-output branch September 25, 2025 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants