forked from cleveragents/cleveragents-core
4d31f0ed02
Add `fmt: OutputFormat` parameter to `main_callback()` in
`src/cleveragents/cli/main.py` and store the selected format in
`ctx.obj["format"]` so all subcommands can read it without needing
their own per-command `--format` flag.
Remove per-command `--format` / `fmt` parameters from `version()`,
`info()`, and `diagnostics()` commands. These commands now read the
format from `ctx.obj.get("format", OutputFormat.RICH.value)`.
The specification states: "The framework supports six distinct output
formats, selectable via the global `--format` flag." This change
aligns the implementation with the spec by making `--format` a global
option on the root `agents` command (via the Typer callback).
All six formats (json, yaml, plain, rich, table, color) are supported
via the global flag and the `-f` shorthand.
Add Behave BDD scenarios covering global `--format` flag propagation
to subcommands for all six formats. Update Robot Framework integration
tests to exercise the global `--format` flag. Update existing tests
that used per-command `--format` for version/info/diagnostics to use
the global flag instead.
ISSUES CLOSED: #2908
85 lines
4.7 KiB
Plaintext
85 lines
4.7 KiB
Plaintext
*** Settings ***
|
|
Documentation Smoke tests for CLI --format flag parity (json/yaml/plain/table/rich)
|
|
... and global --format flag propagation to subcommands.
|
|
Resource ${CURDIR}/common.resource
|
|
Suite Setup Setup Test Environment
|
|
Suite Teardown Cleanup Test Environment
|
|
|
|
*** Variables ***
|
|
${HELPER} ${CURDIR}/helper_cli_formats.py
|
|
|
|
*** Test Cases ***
|
|
Action List Format JSON Outputs Valid JSON
|
|
[Documentation] Verify that ``action list --format json`` emits parseable JSON
|
|
${result}= Run Process ${PYTHON} ${HELPER} action-list-json cwd=${WORKSPACE}
|
|
Log ${result.stdout}
|
|
Log ${result.stderr}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} cli-formats-action-list-json-ok
|
|
|
|
Action Show Format YAML Outputs Valid YAML
|
|
[Documentation] Verify that ``action show --format yaml`` emits parseable YAML
|
|
${result}= Run Process ${PYTHON} ${HELPER} action-show-yaml cwd=${WORKSPACE}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} cli-formats-action-show-yaml-ok
|
|
|
|
Plan Lifecycle List Format JSON Outputs Valid JSON
|
|
[Documentation] Verify that ``plan list --format json`` emits JSON
|
|
${result}= Run Process ${PYTHON} ${HELPER} plan-list-json cwd=${WORKSPACE}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} cli-formats-plan-list-json-ok
|
|
|
|
Plan Status Format Plain Outputs Key-Value Pairs
|
|
[Documentation] Verify that ``plan status <id> --format plain`` emits plain text
|
|
${result}= Run Process ${PYTHON} ${HELPER} plan-status-plain cwd=${WORKSPACE}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} cli-formats-plan-status-plain-ok
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Global --format flag propagation tests (Issue #2908)
|
|
# ---------------------------------------------------------------------------
|
|
|
|
Global Format Flag JSON Propagates To Version Command
|
|
[Documentation] Verify that global ``--format json`` propagates to the version command
|
|
${result}= Run Process ${PYTHON} ${HELPER} global-format-json-version cwd=${WORKSPACE}
|
|
Log ${result.stdout}
|
|
Log ${result.stderr}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} cli-global-format-json-version-ok
|
|
|
|
Global Format Flag YAML Propagates To Version Command
|
|
[Documentation] Verify that global ``--format yaml`` propagates to the version command
|
|
${result}= Run Process ${PYTHON} ${HELPER} global-format-yaml-version cwd=${WORKSPACE}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} cli-global-format-yaml-version-ok
|
|
|
|
Global Format Flag Plain Propagates To Version Command
|
|
[Documentation] Verify that global ``--format plain`` propagates to the version command
|
|
${result}= Run Process ${PYTHON} ${HELPER} global-format-plain-version cwd=${WORKSPACE}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} cli-global-format-plain-version-ok
|
|
|
|
Global Format Flag JSON Propagates To Info Command
|
|
[Documentation] Verify that global ``--format json`` propagates to the info command
|
|
${result}= Run Process ${PYTHON} ${HELPER} global-format-json-info cwd=${WORKSPACE}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} cli-global-format-json-info-ok
|
|
|
|
Global Format Flag JSON Propagates To Diagnostics Command
|
|
[Documentation] Verify that global ``--format json`` propagates to the diagnostics command
|
|
${result}= Run Process ${PYTHON} ${HELPER} global-format-json-diagnostics cwd=${WORKSPACE}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} cli-global-format-json-diagnostics-ok
|
|
|
|
Global Format Shorthand Flag Works
|
|
[Documentation] Verify that global ``-f json`` shorthand propagates to the version command
|
|
${result}= Run Process ${PYTHON} ${HELPER} global-format-shorthand cwd=${WORKSPACE}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} cli-global-format-shorthand-ok
|
|
|
|
All Six Formats Work With Version Command
|
|
[Documentation] Verify all six output formats work via the global --format flag
|
|
${result}= Run Process ${PYTHON} ${HELPER} global-format-all-six cwd=${WORKSPACE}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} cli-global-format-all-six-ok
|