Skip to main content

Module utils

Module utils 

Source
Expand description

Utility functions for click-rs.

This module provides utility functions for path handling, stream access, environment queries, and other common operations needed by CLI applications.

§Reference

Based on Python Click’s utils.py.

Functions§

expand_args
Expand glob patterns in arguments.
expand_path
Expand a path by resolving ~ and environment variables.
format_filename
Format a path for user-friendly display.
get_app_dir
Get the platform-specific application directory.
get_binary_stdin
Get a binary stdin reader.
get_binary_stdout
Get a binary stdout writer.
get_extension
Get the file extension from a path, if any.
get_os_args
Get the command-line arguments.
get_os_args_skip_program
Get the command-line arguments without the program name.
get_terminal_width
Get the terminal width.
get_text_stderr
Get a text stderr writer.
get_text_stdout
Get a text stdout writer.
home_dir
Get the user’s home directory.
is_tty
Check if the output stream is a terminal/TTY.
join_with_conjunction
Join items with a separator and a final conjunction.
make_safe_filename
Make a filename safe by removing or replacing problematic characters.
pluralize
Pluralize a word based on a count.
safecall
Safely encode a string for terminal output.
should_strip_ansi
Check if ANSI escape codes should be stripped from output.
split_arg_string
Parse a string like a shell would: handle quotes, escapes, and whitespace.
strip_extension
Strip the file extension from a path.