Module utils

Module utils 

Source
Expand description

Utility functions for dynamic-cli

This module provides common utility functions used across the framework, including type conversion, string validation, path manipulation, and formatting helpers.

§Sections

  1. Formatting and Display - Format lists, tables, sizes, durations
  2. String Validation - Check and normalize strings
  3. Type Conversion - Parse values with context
  4. Path Manipulation - Normalize and check paths
  5. Test Helpers - Common test utilities

Functions§

detect_type
Detect argument type from string value
format_bytes
Format bytes as human-readable size
format_duration
Format duration in human-readable form
format_numbered_list
Format a list with numbers
format_table
Format a simple table with headers and rows
get_extension
Get file extension in lowercase
has_extension
Check if path has any of the given extensions
is_blank
Check if string is empty or only whitespace
is_valid_email
Check if string looks like an email (basic validation)
normalize
Normalize a string (trim and lowercase)
normalize_path
Normalize path separators (cross-platform)
parse_bool
Parse string to bool
parse_float
Parse string to float with context
parse_int
Parse string to integer with context
truncate
Truncate string to max length with ellipsis