swab(1): untested move to new getopt bindings

This commit is contained in:
dtb 2024-06-28 08:33:31 -06:00
parent 2f87ad948f
commit d07bb7da41
Signed by: trinity
GPG Key ID: 34C0543BBB6AF81B

View File

@ -49,20 +49,16 @@ fn main() -> ExitCode {
let mut force = false;
let mut wordsize: usize = 2;
loop {
match opts.next() {
None => break,
Some(opt) =>
match opt {
Ok(Opt('f', None)) => force = true,
Ok(Opt('w', Some(arg))) => {
match arg.parse::<usize>() {
Ok(w) if w % 2 == 0 => { wordsize = w; () },
_ => { return usage(&argv[0]); },
}
},
_ => { return usage(&argv[0]); }
}
while let Some(opt) = argv.getopt("fw:") {
match opt.opt() {
Ok("f") => force = true,
Ok("w") => {
match arg.parse::<usize>() {
Ok(w) if w % 2 == 0 => { wordsize = w; () },
_ => { return usage(&argv[0]); },
}
},
_ => { return usage(&argv[0]); }
}
}