plexus.cli.shared.command_output module
Standard command output handling for the Plexus task dispatch system.
Provides a clean interface for commands to write structured output files that can be uploaded as task attachments.
- class plexus.cli.shared.command_output.CommandOutputManager(task_id: str | None = None, format_type: str | None = None)
Bases:
objectManages output files for commands in the task dispatch system.
Commands can use this to write structured output that gets automatically uploaded as task attachments.
Initialize the output manager.
- Args:
task_id: The task ID for file naming format_type: The output format (e.g., ‘json’, ‘yaml’, ‘csv’)
- __init__(task_id: str | None = None, format_type: str | None = None)
Initialize the output manager.
- Args:
task_id: The task ID for file naming format_type: The output format (e.g., ‘json’, ‘yaml’, ‘csv’)
- cleanup()
Clean up temporary files and directories.
- get_created_files() → Dict[str, str]
Get all files created by this output manager.
- Returns:
Dict[str, str]: Mapping of filename to full path
- get_output_file_path(filename: str) → str
Get the path for an output file.
- Args:
filename: The name of the output file
- Returns:
str: Full path to the output file
- write_json_output(data: Any, filename: str = 'output.json') → str
Write JSON output to a file.
- Args:
data: The data to write as JSON filename: The output filename
- Returns:
str: Path to the created file
- write_text_output(content: str, filename: str) → str
Write text output to a file.
- Args:
content: The text content to write filename: The output filename
- Returns:
str: Path to the created file
- plexus.cli.shared.command_output.get_format_type() → str | None
Get the current output format type.
- Returns:
Optional[str]: The format type, or None if not set
- plexus.cli.shared.command_output.get_output_manager() → CommandOutputManager | None
Get the global output manager instance.
- plexus.cli.shared.command_output.set_output_manager(manager: CommandOutputManager)
Set the global output manager instance.
- plexus.cli.shared.command_output.should_write_json_output() → bool
Check if commands should write JSON output files.
- Returns:
bool: True if JSON output should be written
- plexus.cli.shared.command_output.write_json_output(data: Any, filename: str = 'output.json') → str | None
Convenience function to write JSON output using the global manager.
- Args:
data: The data to write as JSON filename: The output filename
- Returns:
Optional[str]: Path to created file, or None if no manager
- plexus.cli.shared.command_output.write_text_output(content: str, filename: str) → str | None
Convenience function to write text output using the global manager.
- Args:
content: The text content to write filename: The output filename
- Returns:
Optional[str]: Path to created file, or None if no manager