Maintenance crates.io docs.rs Build Status

clap-num

clap V3 number parsers.

This crate contains functions to validate and parse numerical values from strings provided by [clap v3].

Example

This example allow values for --frequency between 800 Hz and 3.333 MHz, with SI symbols.

```rust use clap::Clap; use clapnum::sinumber_range;

fn frequency(s: &str) -> Result { sinumberrange(s, 800, 3333000) }

[derive(Clap, Debug)]

struct Args { #[clap(short, long, parse(tryfromstr=frequency))] frequency: Option, }

let args = Args::parse(); println!("{:?}", args); ```