Module type_parser

Module type_parser 

Source
Expand description

Type parsing functions

This module provides functions to parse string values into typed values according to the ArgumentType specification. Each type has dedicated parsing logic with detailed error messages.

§Supported Types

  • String: Pass-through (no conversion)
  • Integer: Signed 64-bit integers (i64)
  • Float: 64-bit floating point (f64)
  • Bool: true/false, yes/no, 1/0, on/off (case-insensitive)
  • Path: File system paths (validated as PathBuf)

§Example

use dynamic_cli::parser::type_parser::{parse_value, parse_integer};
use dynamic_cli::config::schema::ArgumentType;

// Parse a value according to its type
let result = parse_value("42", ArgumentType::Integer).unwrap();
assert_eq!(result, "42");

// Parse directly to specific type
let number = parse_integer("42").unwrap();
assert_eq!(number, 42);

Functions§

parse_bool
Parse a string as a boolean
parse_float
Parse a string as a floating-point number
parse_integer
Parse a string as a signed integer
parse_path
Parse a string as a file system path
parse_value
Parse a string value according to its expected type