coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

Replace deprecated value_of() with get_one()

Open cakebaker opened this issue 3 years ago • 1 comments

This PR replaces the usage of clap's deprecated value_of() with get_one().

cakebaker avatar Aug 16 '22 11:08 cakebaker

I tried this myself and got kinda stuck... Unless I'm missing something this API seems very weird. The use case we have most is that we just need some &str and that seems to be impossible because get_one::<T> returns &T and we can't move out of that reference. T can also not be str (without &), because that doesn't implement Clone. So we need to_owned() and cloned() calls all over the place, which defeats the purpose of using &str over String in the first place.

tertsdiepraam avatar Aug 18 '22 22:08 tertsdiepraam

Thanks I am a bit surprised that it is only String as input

sylvestre avatar Sep 27 '22 17:09 sylvestre

I'm sure there are a lot of cases where we can use a more specific value parser instead, but that will require more work to get right.

tertsdiepraam avatar Sep 27 '22 19:09 tertsdiepraam