crates.io docs.rs Build Status

clap-num

clap number parsers.

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

Example

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

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

fn parsefrequency(s: &str) -> Result { sinumberrange(s, 800, 3333_000) }

[derive(Parser, Debug)]

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

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