util: split getopt error handling into utility function
This commit is contained in:
parent
d8e267d5ba
commit
7a9866a4e2
2 changed files with 13 additions and 14 deletions
10
esv.d
10
esv.d
|
@ -20,7 +20,6 @@
|
|||
|
||||
module esv;
|
||||
|
||||
import std.algorithm : startsWith;
|
||||
import std.conv : to, ConvException;
|
||||
import std.file : exists, mkdirRecurse, write, FileException;
|
||||
import std.format : format;
|
||||
|
@ -76,14 +75,7 @@ main(string[] args)
|
|||
"V", &VFlag,
|
||||
);
|
||||
} catch (GetOptException e) {
|
||||
string opt = extractFlag(e);
|
||||
|
||||
enforceDie(!e.msg.startsWith("Unrecognized option"),
|
||||
"unknown option " ~ opt);
|
||||
enforceDie(!e.msg.startsWith("Missing value for argument"),
|
||||
"missing argument for option " ~ opt);
|
||||
|
||||
die(e.msg); /* catch-all */
|
||||
handleOptError(e.msg);
|
||||
}
|
||||
|
||||
if (VFlag) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue