These are chat archives for kbknapp/clap-rs

22nd
Jan 2018
Emil Gardström
@Emilgardis
Jan 22 2018 12:33

@kbknapp no, the inverse, if --all is used, --count should have no default. i.e app --all doesn't set --count. app --count 5 and app should result in the same thing. right now, it's only possible to make --count be "", what I'd want is to make .value_of("count") return None, instead of Some("")

Of course, right now I fix this easily with

let count: Option<u32> = if matches.is_present("all") {
        None
    } else {
        matches.value_of("count").map(parse_u32)
};

But I'd like to skip all that and just have

let count: Option<u32> = matches.value_of("count").map(parse_u32);
Also, you @'ed the wrong person
Kevin K.
@kbknapp
Jan 22 2018 14:47
@Emilgardis apologizies for the wrong @ ! I understand now. Unfortunately, the is_present/map combo you're using is the best way right now. Since I'm in the middle of making 3.x your suggestion is something I could do. I'd be a little nervous including that change in a server compatible update because although I think it technically won't break anything, I've had a good bit if push back from similar changes I've either made or tried to make in the past.
I'm on mobile right now, so some if the auto corrected words are wrong, but you should get the gist ;)