Skip to content

Add generic --output option for parseable CLI output (rich, plain, json)#10

Merged
sokripon merged 5 commits intomainfrom
copilot/add-plain-output-option
Jan 16, 2026
Merged

Add generic --output option for parseable CLI output (rich, plain, json)#10
sokripon merged 5 commits intomainfrom
copilot/add-plain-output-option

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

Adds a generic --output/-o option to all CLI commands, enabling machine-parseable output in multiple formats for easy scripting and automation.

Changes

  • Generic --output/-o option: Added to CLI callback with choices: rich (default), plain, json
  • OutputFormat enum: New enum class for output format types, making it easy to add new formats
  • output_data() helper function: Centralized output handling for consistent formatting across all commands
  • Output formats:
    • rich: Beautiful Rich-formatted output with panels, tables, and colors (default)
    • plain: Simple key=value pairs or tab-separated values for shell scripting
    • json: JSON output for programmatic consumption
  • Updated README: Added documentation for the --output option with examples for all formats

Extensibility

Adding a new format (e.g., YAML) only requires:

  1. Adding a new value to the OutputFormat enum
  2. Adding a case to the output_data() function

Example Usage

# Default rich output
tacomail create

# Plain output for shell scripts
tacomail --output plain create
tacomail -o plain list user@tacomail.de

# JSON output for parsing
tacomail --output json create
tacomail -o json list user@tacomail.de

Testing

  • 27 CLI tests covering plain and JSON output formats for all commands

Security Summary

No security vulnerabilities were discovered.

Original prompt

All the commands from the CLI should have an option for plain output to make it easier to parse the output


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: sokripon <79755465+sokripon@users.noreply.github.com>
Copilot AI changed the title [WIP] Add plain output option for CLI commands Add --plain option for parseable CLI output Jan 16, 2026
Copilot AI requested a review from sokripon January 16, 2026 16:01
@sokripon
Copy link
Owner

@copilot It should be a more generic, so adding other outputing formats like json is easier in the future

Copilot AI and others added 2 commits January 16, 2026 16:19
Co-authored-by: sokripon <79755465+sokripon@users.noreply.github.com>
Co-authored-by: sokripon <79755465+sokripon@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 16, 2026

@copilot It should be a more generic, so adding other outputing formats like json is easier in the future

Refactored to a generic --output/-o option with an enum supporting rich, plain, and json formats. Adding new formats only requires adding a value to the OutputFormat enum and a case to the output_data() helper function. Commit: 212698f

@sokripon
Copy link
Owner

@copilot Great, now also update the readme

Co-authored-by: sokripon <79755465+sokripon@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 16, 2026

@copilot Great, now also update the readme

Updated the README with documentation for the --output option including:

  • Added to Global Options section
  • New "Output Formats" section with examples for rich, plain, and json formats
  • Updated workflow examples to show how to use plain/JSON output for shell scripting

Commit: b28421f

Copilot AI changed the title Add --plain option for parseable CLI output Add generic --output option for parseable CLI output (rich, plain, json) Jan 16, 2026
@sokripon sokripon marked this pull request as ready for review January 16, 2026 17:53
@sokripon sokripon merged commit 71afcad into main Jan 16, 2026
2 checks passed
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