swab(1): untested move to new getopt bindings
This commit is contained in:
parent
2f87ad948f
commit
d07bb7da41
24
src/swab.rs
24
src/swab.rs
@ -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]); }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user