Output

The output module provides text and JSON formatting helpers.

class oduit.output.OutputFormatter(format_type: str = 'text', non_interactive: bool = False)[source]

Bases: object

Handles different output formats and modes.

__init__(format_type: str = 'text', non_interactive: bool = False)[source]
output(message: str, level: str = 'info', data: dict[str, Any] | None = None) None[source]

Output a message in the configured format.

print_result(data: dict[str, Any], message: str = 'Operation completed') None[source]

Print operation result with data.

print_error_result(error_msg: str, error_code: int = 1) None[source]

Print error result and exit with code.

oduit.output.configure_output(format_type: str = 'text', non_interactive: bool = False) None[source]

Configure the global output formatter.

oduit.output.print_info(msg: str, data: dict[str, Any] | None = None) None[source]
oduit.output.print_success(msg: str, data: dict[str, Any] | None = None) None[source]
oduit.output.print_warning(msg: str, data: dict[str, Any] | None = None) None[source]
oduit.output.print_error(msg: str, data: dict[str, Any] | None = None) None[source]
oduit.output.print_result(data: dict[str, Any], message: str = 'Operation completed') None[source]

Print operation result with data.

oduit.output.print_error_result(error_msg: str, error_code: int = 1) None[source]

Print error result and exit with code.

Usage Examples

from oduit import configure_output, print_error, print_info, print_result

configure_output(format_type="json", non_interactive=True)
print_info("Starting operation")
print_result({"operation": "demo", "success": True}, "Operation completed")
print_error("Something went wrong")

Key APIs

  • configure_output(format_type="text", non_interactive=False)

  • print_info(), print_success(), print_warning(), print_error()

  • print_result(data, message=...)

  • print_error_result(error_msg, error_code=1)

  • OutputFormatter(format_type="text", non_interactive=False)