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

The [repl] sub-module provides a shared REPL scaffold and is enabled via the repl crate feature.

Enums§

OutputFormat
Output format for CLI results.

Functions§

exit_if
Exits the process with an error code if condition is true.
expand_home_dir
Expand a leading ~/ in a path to the user’s home directory.
parse_package_spec
Parse a name@version package specification into (name, version).
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.