4d31f0ed02
CI / lint (pull_request) Successful in 21s
CI / quality (pull_request) Successful in 34s
CI / typecheck (pull_request) Successful in 51s
CI / security (pull_request) Successful in 1m0s
CI / build (pull_request) Successful in 19s
CI / helm (pull_request) Successful in 24s
CI / unit_tests (pull_request) Failing after 7m5s
CI / docker (pull_request) Has been skipped
CI / e2e_tests (pull_request) Successful in 16m51s
CI / integration_tests (pull_request) Successful in 23m16s
CI / coverage (pull_request) Successful in 10m39s
CI / status-check (pull_request) Failing after 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 56m46s
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
137 lines
5.6 KiB
Gherkin
137 lines
5.6 KiB
Gherkin
Feature: CLI consistency and UX polish
|
|
As a developer
|
|
I want all CLI commands to follow consistent UX patterns
|
|
So that the tool is predictable and easy to use
|
|
|
|
# -----------------------------------------------------------------
|
|
# Exit code constants
|
|
# -----------------------------------------------------------------
|
|
|
|
Scenario: Exit code constants are defined
|
|
Given the CLI constants module is imported
|
|
Then EXIT_SUCCESS should equal 0
|
|
And EXIT_ERROR should equal 1
|
|
And EXIT_USAGE should equal 2
|
|
And EXIT_NOT_FOUND should equal 3
|
|
And EXIT_CONFLICT should equal 4
|
|
|
|
# -----------------------------------------------------------------
|
|
# Error formatting
|
|
# -----------------------------------------------------------------
|
|
|
|
Scenario: cli_error displays standardized error and exits
|
|
Given the CLI errors module is imported
|
|
When I call cli_error with only message "something broke"
|
|
Then the process should exit with code 1
|
|
And the stderr output should contain "Error:"
|
|
And the stderr output should contain "something broke"
|
|
|
|
Scenario: cli_error displays hint when provided
|
|
Given the CLI errors module is imported
|
|
When I call cli_error with message "not found" and hint "check the name"
|
|
Then the process should exit with code 1
|
|
And the stderr output should contain "Hint: check the name"
|
|
|
|
Scenario: cli_error uses custom exit code
|
|
Given the CLI errors module is imported
|
|
When I call cli_error with message "bad usage" and exit code 2
|
|
Then the process should exit with code 2
|
|
|
|
Scenario: cli_warning displays warning without exiting
|
|
Given the CLI errors module is imported
|
|
When I call cli_warning with only message "heads up"
|
|
Then the stderr output should contain "Warning:"
|
|
And the stderr output should contain "heads up"
|
|
|
|
Scenario: cli_warning displays hint when provided
|
|
Given the CLI errors module is imported
|
|
When I call cli_warning with message "slow" and hint "use cache"
|
|
Then the stderr output should contain "Hint: use cache"
|
|
|
|
Scenario: cli_not_found formats correctly and exits with code 3
|
|
Given the CLI errors module is imported
|
|
When I call cli_not_found with type "Project" and name "missing-proj"
|
|
Then the process should exit with code 3
|
|
And the stderr output should contain "Project 'missing-proj' not found"
|
|
And the stderr output should contain "Hint:"
|
|
|
|
# -----------------------------------------------------------------
|
|
# Format constants
|
|
# -----------------------------------------------------------------
|
|
|
|
Scenario: Format constants are consistent
|
|
Given the CLI constants module is imported
|
|
Then FORMAT_HELP should mention "json"
|
|
And FORMAT_HELP should mention "yaml"
|
|
And FORMAT_HELP should mention "plain"
|
|
And DEFAULT_FORMAT should equal "rich"
|
|
And VALID_FORMATS should contain "json"
|
|
And VALID_FORMATS should contain "yaml"
|
|
And VALID_FORMATS should contain "plain"
|
|
And VALID_FORMATS should contain "table"
|
|
And VALID_FORMATS should contain "rich"
|
|
|
|
Scenario: Named format shortcut constants are defined
|
|
Given the CLI constants module is imported
|
|
Then FORMAT_TEXT should equal "plain"
|
|
And FORMAT_JSON should equal "json"
|
|
And FORMAT_TABLE should equal "table"
|
|
|
|
# -----------------------------------------------------------------
|
|
# Help text consistency
|
|
# -----------------------------------------------------------------
|
|
|
|
Scenario: Main CLI provides help output
|
|
Given a CLI consistency test runner
|
|
When I invoke the CLI with "--help"
|
|
Then the invoked CLI exit code should be 0
|
|
And the invoked CLI output should contain "AI-powered development assistant"
|
|
|
|
Scenario: Version command provides output
|
|
Given a CLI consistency test runner
|
|
When I invoke the CLI with "--version"
|
|
Then the invoked CLI exit code should be 0
|
|
And the invoked CLI output should contain "CleverAgents"
|
|
|
|
Scenario: Invalid command returns usage exit code
|
|
Given a CLI consistency test runner
|
|
When I invoke the CLI with "nonexistent-command-xyz"
|
|
Then the invoked CLI exit code should be 2
|
|
|
|
# -----------------------------------------------------------------
|
|
# Shell completion command
|
|
# -----------------------------------------------------------------
|
|
|
|
Scenario: Completion command exists
|
|
Given a CLI consistency test runner
|
|
When I invoke the CLI with "completion --help"
|
|
Then the invoked CLI exit code should be 0
|
|
And the invoked CLI output should contain "completion"
|
|
|
|
Scenario: Completion rejects unsupported shell
|
|
Given a CLI consistency test runner
|
|
When I invoke the CLI with "completion ksh"
|
|
Then the invoked CLI exit code should be 2
|
|
|
|
# -----------------------------------------------------------------
|
|
# JSON/text format switching
|
|
# -----------------------------------------------------------------
|
|
|
|
Scenario: Version command supports JSON format via global --format flag
|
|
Given a CLI consistency test runner
|
|
When I invoke the CLI with "--format json version"
|
|
Then the invoked CLI exit code should be 0
|
|
And the invoked CLI output should be valid JSON
|
|
|
|
Scenario: Version command supports YAML format via global --format flag
|
|
Given a CLI consistency test runner
|
|
When I invoke the CLI with "--format yaml version"
|
|
Then the invoked CLI exit code should be 0
|
|
And the invoked CLI output should contain "version:"
|
|
|
|
Scenario: Version command supports plain format via global --format flag
|
|
Given a CLI consistency test runner
|
|
When I invoke the CLI with "--format plain version"
|
|
Then the invoked CLI exit code should be 0
|
|
And the invoked CLI output should contain "version:"
|