pub fn detect_type(value: &str) -> ArgumentTypeExpand description
Detect argument type from string value
Tries to detect the most appropriate type for a string value.
§Detection Order
- Bool (true/false/yes/no/1/0/on/off)
- Integer (parseable as i64)
- Float (parseable as f64 and contains ‘.’)
- Path (starts with /, ./, ../, or contains )
- String (default)
§Example
assert_eq!(detect_type("42"), ArgumentType::Integer);
assert_eq!(detect_type("3.14"), ArgumentType::Float);
assert_eq!(detect_type("true"), ArgumentType::Bool);
assert_eq!(detect_type("/path/to/file"), ArgumentType::Path);
assert_eq!(detect_type("hello"), ArgumentType::String);