Expand description
Utility functions for permissions, formatting, and error handling.
Functions§
- check_
root - Check if the program is running with root privileges (Unix) or an elevated/Administrator token (Windows).
- confirm
- Ask for user confirmation
- elevate_
if_ needed - Prompt for sudo elevation if not already root Returns true if elevation succeeded or already root, false otherwise
- execute_
with_ sudo - Execute a command with sudo if not already root This function handles terminal raw mode properly for TUI applications It assumes sudo credentials are already cached (via password dialog or sudo -v)
- format_
size - Format bytes into human-readable sizes
- get_
size - Get the size of a directory or file in bytes.
- print_
error - Print an error message
- print_
header - Print a header with a colorful banner
- print_
success - Print a success message
- print_
warning - Print a warning message
- supports_
sudo_ prompt - Whether this platform’s elevation model matches the interactive
sudo-password-prompt flow (Unix:
sudo -S). Windows uses UAC/Administrator tokens instead, which front-ends should present very differently (there is no password to type — the user must relaunch the process elevated).