Skip to content

feat(cli): add support for -o in ado contexts#821

Merged
AlessandroPomponio merged 2 commits into
mainfrom
ap_817_refactor_ado_contexts
Apr 10, 2026
Merged

feat(cli): add support for -o in ado contexts#821
AlessandroPomponio merged 2 commits into
mainfrom
ap_817_refactor_ado_contexts

Conversation

@AlessandroPomponio
Copy link
Copy Markdown
Member

Summary

This PR refactors the ado contexts command to improve its output formatting and consistency. The main changes include:

  • Replacing the --simple flag with a more flexible --output / -o option that supports multiple formats (default, name, yaml, json)
  • Renaming the "DEFAULT" column to "ACTIVE" in the context listing table for better clarity
  • Improving error handling and messaging for invalid contexts
  • Cleaning up code formatting and removing unnecessary whitespace
  • Updating documentation and help text to reflect the new options

Resolves #817

Files Changed

📄 orchestrator/cli/commands/context.py

Refactored the list_contexts function to replace the boolean --simple flag with a more flexible --output / -o option that accepts different output formats (default, name, yaml, json). Updated the command documentation with better examples showing the new output format options. Removed the separate logic for displaying the active context message and simplified the function by delegating output formatting to the get_context function. Also cleaned up excessive blank lines in docstrings.

📄 orchestrator/cli/resources/context/get.py

Removed the simplify_output parameter and refactored output handling to use the output_format parameter consistently. Renamed "DEFAULT" column to "ACTIVE" in the context dataframe for better clarity. Improved error handling for invalid contexts with more helpful error messages including file paths and remediation hints. Simplified the NAME format output logic and removed the now-unused _simple_contexts_formatting function. Updated comments to better describe the behavior.

📄 orchestrator/cli/utils/output/prints.py

Added a new constant ADO_NO_CONTEXT_AVAILABLE_ERROR to centralize the error message displayed when no contexts are available, improving consistency and maintainability across the codebase.

📄 tests/ado/context/test_ado_context.py

Updated all test cases to use the new --output name / -o name option instead of the deprecated --simple flag. Renamed test variables from *_simple_output_* to *_name_output_* to reflect the new naming convention. All test assertions remain functionally equivalent but now test the new interface.

Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
Signed-off-by: Alessandro Pomponio <alessandro.pomponio1@ibm.com>
@AlessandroPomponio AlessandroPomponio added this pull request to the merge queue Apr 10, 2026
Merged via the queue into main with commit cf1dbef Apr 10, 2026
19 checks passed
@AlessandroPomponio AlessandroPomponio deleted the ap_817_refactor_ado_contexts branch April 10, 2026 14:38
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.

refactor(cli): make ado contexts uniform with ado get context

2 participants