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;
|
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) {
|
void main(string[] argv) {
|
||||||
Opts opts = defaultOpts();
|
Opts opts = defaultOpts();
|
||||||
|
|
||||||
GetoptResult args = getopt(
|
try {
|
||||||
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,
|
GetoptResult args = getopt(
|
||||||
"col", "terminal width", &opts.col,
|
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,
|
std.getopt.config.required,
|
||||||
"row", "terminal height", &opts.row,
|
"col", "terminal width", &opts.col,
|
||||||
|
|
||||||
std.getopt.config.required,
|
std.getopt.config.required,
|
||||||
"status", "previous command exit code", &opts.status,
|
"row", "terminal height", &opts.row,
|
||||||
|
|
||||||
"pathlen", "set length of displayed path", &opts.pathlen,
|
std.getopt.config.required,
|
||||||
"pchar", "override default prompt character", &opts.pchar,
|
"status", "previous command exit code", &opts.status,
|
||||||
);
|
|
||||||
|
|
||||||
if (args.helpWanted) {
|
"pathlen", "set length of displayed path", &opts.pathlen,
|
||||||
defaultGetoptPrinter("prim prompt:\n", args.options);
|
"pchar", "override default prompt character", &opts.pchar,
|
||||||
writeln("\nEnvironment:\n",
|
);
|
||||||
"\tNO_COLOR\tsee https://no-color.org");
|
|
||||||
|
if (args.helpWanted) {
|
||||||
|
printHelp(args);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
writeln(e.msg);
|
||||||
|
writeln("try '--help' for more information");
|
||||||
}
|
}
|
||||||
|
|
||||||
dorun(opts);
|
dorun(opts);
|
||||||
|
Loading…
Reference in New Issue
Block a user