Catch flag parse error
This commit is contained in:
parent
49768a38a7
commit
36c8b4d2d7
48
source/app.d
48
source/app.d
@ -19,33 +19,43 @@ 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();
|
||||
|
||||
GetoptResult args = getopt(
|
||||
argv,
|
||||
std.getopt.config.bundling,
|
||||
"ps1|p", "print PS1", &opts.ps1,
|
||||
"rps1|r", "print RPS1", &opts.rps1,
|
||||
"preexec|x", "print preexec", &opts.preexec,
|
||||
try {
|
||||
|
||||
std.getopt.config.required,
|
||||
"col", "terminal width", &opts.col,
|
||||
GetoptResult args = getopt(
|
||||
argv,
|
||||
std.getopt.config.bundling,
|
||||
"ps1|p", "print PS1", &opts.ps1,
|
||||
"rps1|r", "print RPS1", &opts.rps1,
|
||||
"preexec|x", "print preexec", &opts.preexec,
|
||||
|
||||
std.getopt.config.required,
|
||||
"row", "terminal height", &opts.row,
|
||||
std.getopt.config.required,
|
||||
"col", "terminal width", &opts.col,
|
||||
|
||||
std.getopt.config.required,
|
||||
"status", "previous command exit code", &opts.status,
|
||||
std.getopt.config.required,
|
||||
"row", "terminal height", &opts.row,
|
||||
|
||||
"pathlen", "set length of displayed path", &opts.pathlen,
|
||||
"pchar", "override default prompt character", &opts.pchar,
|
||||
);
|
||||
std.getopt.config.required,
|
||||
"status", "previous command exit code", &opts.status,
|
||||
|
||||
if (args.helpWanted) {
|
||||
defaultGetoptPrinter("prim prompt:\n", args.options);
|
||||
writeln("\nEnvironment:\n",
|
||||
"\tNO_COLOR\tsee https://no-color.org");
|
||||
"pathlen", "set length of displayed path", &opts.pathlen,
|
||||
"pchar", "override default prompt character", &opts.pchar,
|
||||
);
|
||||
|
||||
if (args.helpWanted) {
|
||||
printHelp(args);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
writeln(e.msg);
|
||||
writeln("try '--help' for more information");
|
||||
}
|
||||
|
||||
dorun(opts);
|
||||
|
Loading…
Reference in New Issue
Block a user