Catch flag parse error

This commit is contained in:
Shav Kinderlehrer 2023-08-10 11:55:20 -04:00
parent 49768a38a7
commit 36c8b4d2d7

View File

@ -19,9 +19,17 @@ Opts defaultOpts() {
return opts;
}
void printHelp(GetoptResult args) {
defaultGetoptPrinter("prim prompt:\n", args.options);
writeln("\nEnvironment:\n",
"\tNO_COLOR\tsee https://no-color.org");
}
void main(string[] argv) {
Opts opts = defaultOpts();
try {
GetoptResult args = getopt(
argv,
std.getopt.config.bundling,
@ -43,9 +51,11 @@ void main(string[] argv) {
);
if (args.helpWanted) {
defaultGetoptPrinter("prim prompt:\n", args.options);
writeln("\nEnvironment:\n",
"\tNO_COLOR\tsee https://no-color.org");
printHelp(args);
}
} catch (Exception e) {
writeln(e.msg);
writeln("try '--help' for more information");
}
dorun(opts);