forked from HAL9000/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
157 lines
6.4 KiB
Gherkin
157 lines
6.4 KiB
Gherkin
Feature: Global --format flag propagation to subcommands
|
|
As a developer using the CleverAgents CLI
|
|
I want the --format flag to be a global option on the root `agents` command
|
|
So that I can set the output format once and have it apply to all subcommands
|
|
Per the specification: "The framework supports six distinct output formats,
|
|
selectable via the global --format flag."
|
|
|
|
Background:
|
|
Given the global format flag test runner is set up
|
|
|
|
# -----------------------------------------------------------------------
|
|
# Subtask 1 & 2: main_callback accepts --format and stores in ctx.obj
|
|
# -----------------------------------------------------------------------
|
|
|
|
Scenario: Global --format json flag is accepted by the root command
|
|
When I invoke the CLI with global args "--format json version"
|
|
Then the global format command should succeed
|
|
And the global format output should be valid JSON
|
|
|
|
Scenario: Global --format yaml flag is accepted by the root command
|
|
When I invoke the CLI with global args "--format yaml version"
|
|
Then the global format command should succeed
|
|
And the global format output should be valid YAML
|
|
|
|
Scenario: Global --format plain flag is accepted by the root command
|
|
When I invoke the CLI with global args "--format plain version"
|
|
Then the global format command should succeed
|
|
And the global format output should contain plain text
|
|
|
|
Scenario: Global --format rich flag is accepted by the root command
|
|
When I invoke the CLI with global args "--format rich version"
|
|
Then the global format command should succeed
|
|
|
|
Scenario: Global --format table flag is accepted by the root command
|
|
When I invoke the CLI with global args "--format table version"
|
|
Then the global format command should succeed
|
|
|
|
Scenario: Global --format color flag is accepted by the root command
|
|
When I invoke the CLI with global args "--format color version"
|
|
Then the global format command should succeed
|
|
|
|
Scenario: Global -f shorthand flag is accepted by the root command
|
|
When I invoke the CLI with global args "-f json version"
|
|
Then the global format command should succeed
|
|
And the global format output should be valid JSON
|
|
|
|
# -----------------------------------------------------------------------
|
|
# Subtask 3: version, info, diagnostics read format from global ctx.obj
|
|
# -----------------------------------------------------------------------
|
|
|
|
Scenario: version command reads format from global ctx.obj
|
|
When I invoke the CLI with global args "--format json version"
|
|
Then the global format command should succeed
|
|
And the global format output should be valid JSON
|
|
And the global format JSON output should contain key "version"
|
|
|
|
Scenario: info command reads format from global ctx.obj
|
|
When I invoke the CLI with global args "--format json info"
|
|
Then the global format command should succeed
|
|
And the global format output should be valid JSON
|
|
|
|
Scenario: diagnostics command reads format from global ctx.obj
|
|
When I invoke the CLI with global args "--format json diagnostics"
|
|
Then the global format command should succeed
|
|
And the global format output should be valid JSON
|
|
|
|
Scenario: version command defaults to rich format when no --format given
|
|
When I invoke the CLI with global args "version"
|
|
Then the global format command should succeed
|
|
|
|
Scenario: info command defaults to rich format when no --format given
|
|
When I invoke the CLI with global args "info"
|
|
Then the global format command should succeed
|
|
|
|
Scenario: diagnostics command defaults to rich format when no --format given
|
|
When I invoke the CLI with global args "diagnostics"
|
|
Then the global format command should succeed
|
|
|
|
# -----------------------------------------------------------------------
|
|
# Subtask 4: ctx.obj["format"] is stored and accessible
|
|
# -----------------------------------------------------------------------
|
|
|
|
Scenario: ctx.obj stores the selected format value json
|
|
When I call main_callback directly with format "json"
|
|
Then the context object should have format "json"
|
|
|
|
Scenario: ctx.obj stores yaml format value
|
|
When I call main_callback directly with format "yaml"
|
|
Then the context object should have format "yaml"
|
|
|
|
Scenario: ctx.obj stores plain format value
|
|
When I call main_callback directly with format "plain"
|
|
Then the context object should have format "plain"
|
|
|
|
Scenario: ctx.obj stores rich format value (default)
|
|
When I call main_callback directly with format "rich"
|
|
Then the context object should have format "rich"
|
|
|
|
Scenario: ctx.obj stores table format value
|
|
When I call main_callback directly with format "table"
|
|
Then the context object should have format "table"
|
|
|
|
Scenario: ctx.obj stores color format value
|
|
When I call main_callback directly with format "color"
|
|
Then the context object should have format "color"
|
|
|
|
# -----------------------------------------------------------------------
|
|
# All six formats work end-to-end with version command
|
|
# -----------------------------------------------------------------------
|
|
|
|
Scenario Outline: All six formats work with the version command via global flag
|
|
When I invoke the CLI with global args "--format <format> version"
|
|
Then the global format command should succeed
|
|
|
|
Examples:
|
|
| format |
|
|
| json |
|
|
| yaml |
|
|
| plain |
|
|
| rich |
|
|
| table |
|
|
| color |
|
|
|
|
# -----------------------------------------------------------------------
|
|
# All six formats work end-to-end with info command
|
|
# -----------------------------------------------------------------------
|
|
|
|
Scenario Outline: All six formats work with the info command via global flag
|
|
When I invoke the CLI with global args "--format <format> info"
|
|
Then the global format command should succeed
|
|
|
|
Examples:
|
|
| format |
|
|
| json |
|
|
| yaml |
|
|
| plain |
|
|
| rich |
|
|
| table |
|
|
| color |
|
|
|
|
# -----------------------------------------------------------------------
|
|
# All six formats work end-to-end with diagnostics command
|
|
# -----------------------------------------------------------------------
|
|
|
|
Scenario Outline: All six formats work with the diagnostics command via global flag
|
|
When I invoke the CLI with global args "--format <format> diagnostics"
|
|
Then the global format command should succeed
|
|
|
|
Examples:
|
|
| format |
|
|
| json |
|
|
| yaml |
|
|
| plain |
|
|
| rich |
|
|
| table |
|
|
| color |
|