Skip to main content

Module cli

Module cli 

Source
Expand description

CLI utilities for command-line applications.

This module provides common patterns for CLI applications including:

  • Reading input from files, stdin, or command-line arguments
  • Writing output to files or stdout
  • Formatting and printing results with different output formats
  • Error handling and exit codes

Enums§

OutputFormat
Output format for CLI results.

Functions§

exit_if
Exits the process with an error code if condition is true.
print_result
Prints a result, handling errors with proper formatting.
print_with_format
Prints a value with the specified output format.
read_input
Reads input from a file, inline string, or stdin.
read_json
Reads and parses JSON from a file.
write_output
Writes content to a file or stdout.