swab(1): updates getopt usage

This commit is contained in:
Emma Tebibyte 2024-07-08 13:22:38 -06:00
parent 1fd768057c
commit ca6865688a
Signed by untrusted user: emma
GPG Key ID: 06FA419A1698C270

View File

@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2024 DTB <trinity@trinity.moe> * Copyright (c) 2024 DTB <trinity@trinity.moe>
* Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
* SPDX-License-Identifier: AGPL-3.0-or-later * SPDX-License-Identifier: AGPL-3.0-or-later
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
@ -54,12 +55,10 @@ fn main() -> ExitCode {
while let Some(opt) = argv.getopt(":w:") { while let Some(opt) = argv.getopt(":w:") {
match opt.opt() { match opt.opt() {
Ok("w") => { Ok("w") => {
if let Some(arg) = opt.arg() { match opt.arg().unwrap().parse::<usize>() {
match arg.parse::<usize>() { Ok(w) if w % 2 == 0 => { wordsize = w; },
Ok(w) if w % 2 == 0 => { wordsize = w; () },
_ => { return usage(&argv[0]); }, _ => { return usage(&argv[0]); },
} }
}
optind = opt.ind(); optind = opt.ind();
}, },
_ => { return usage(&argv[0]); } _ => { return usage(&argv[0]); }