Skip to content

Validate example commands that use --cli-input-* options - #10824

Merged
luigi617 merged 1 commit into
code-example-ci-9from
code-example-ci-validator
Oct 30, 2026
Merged

luigi617 merged 1 commit into
code-example-ci-9from
code-example-ci-validator

Conversation

@luigi617

Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of changes:
Validate example commands that use --cli-input-* options

verify_cli_commands_valid skipped every example command that used --cli-input-json, --cli-input-yaml or --generate-cli-skeleton (marked as a TODO), because the test parser reported their required arguments as missing. These commands are now validated like any other example.

  • Removed the TODO skip in CommandValidator.validate_cli_command in tests/functional/docs/test_examples.py
  • Added _cli_required_args, which applies the CLI's own rule for required arguments: it emits before-building-argument-table-parser.<service>.<operation> so the CLI's handlers make the other arguments optional when --cli-input-* or --generate-cli-skeleton is used, and restores the argument table afterwards for the other examples of the same operation
  • Command parsing now stops at shell redirects and pipes, so commands such as --generate-cli-skeleton > skeleton.json don't pass > to the CLI
  • The service and operation names of these commands (146 example files) are now checked. Unknown options and argument values are still not checked, which is unchanged for all examples

Testing

  • Run pytest tests/functional/docs/test_examples.py -n auto
=== 64297 passed in 26.34s =====

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

The example command check skipped any command that used --cli-input-json,
--cli-input-yaml or --generate-cli-skeleton, because the test parser
reported their required arguments as missing. Apply the same rule the CLI
applies instead, by emitting before-building-argument-table-parser so its
handlers make the other arguments optional, and restore the argument
table afterwards. The service and operation names of these commands are
now checked like those of any other example.

Stop parsing at shell redirects and pipes, so commands such as
"--generate-cli-skeleton > skeleton.json" are not read as passing ">" to
the CLI.
@luigi617
luigi617 added this pull request to stack #10814 October 29, 2026 20:02
@luigi617
luigi617 requested a review from a team as a code owner October 29, 2026 20:02
@luigi617
luigi617 merged commit cbf43e4 into v2 Oct 30, 2026
144 of 148 checks passed
@luigi617
luigi617 deleted the code-example-ci-validator branch October 30, 2026 14:52
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.

2 participants