esv: remove bad use of UFCS
This commit is contained in:
parent
1ba023122a
commit
1ed36260f3
1 changed files with 14 additions and 9 deletions
23
esv.d
23
esv.d
|
@ -93,10 +93,12 @@ main(string[] args)
|
||||||
"V", &VFlag,
|
"V", &VFlag,
|
||||||
);
|
);
|
||||||
} catch (GetOptException e) {
|
} catch (GetOptException e) {
|
||||||
|
string opt = extractOpt(e);
|
||||||
|
|
||||||
enforceDie(!e.msg.startsWith("Unrecognized option"),
|
enforceDie(!e.msg.startsWith("Unrecognized option"),
|
||||||
"unknown option " ~ e.extractOpt());
|
"unknown option " ~ opt);
|
||||||
enforceDie(!e.msg.startsWith("Missing value for argument"),
|
enforceDie(!e.msg.startsWith("Missing value for argument"),
|
||||||
"missing argument for option " ~ e.extractOpt());
|
"missing argument for option " ~ opt);
|
||||||
|
|
||||||
die(e.msg); /* catch-all */
|
die(e.msg); /* catch-all */
|
||||||
}
|
}
|
||||||
|
@ -112,11 +114,13 @@ main(string[] args)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length < 3) {
|
if (args.length < 3) {
|
||||||
stderr.writefln("usage: %s [-aFfHhNnRrV] [-C config] [-l length] [-s query] book verses", args[0].baseName());
|
stderr.writefln(
|
||||||
|
"usage: %s [-aFfHhNnRrV] [-C config] [-l length] [-s query] book verses",
|
||||||
|
baseName(args[0]));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
enforceDie(bookValid(args[1].parseBook()),
|
enforceDie(bookValid(parseBook(args[1])),
|
||||||
"book '%s' does not exist", args[1]);
|
"book '%s' does not exist", args[1]);
|
||||||
enforceDie(verseValid(args[2]),
|
enforceDie(verseValid(args[2]),
|
||||||
"invalid verse format '%s'", args[2]);
|
"invalid verse format '%s'", args[2]);
|
||||||
|
@ -124,17 +128,18 @@ main(string[] args)
|
||||||
/* determine configuration file: options take first priority,
|
/* determine configuration file: options take first priority,
|
||||||
* then environment variables, and then the default path */
|
* then environment variables, and then the default path */
|
||||||
config:
|
config:
|
||||||
configPath = environment.get(cf.configEnv, cf.configPath).expandTilde();
|
configPath = environment.get(cf.configEnv, cf.configPath)
|
||||||
|
.expandTilde();
|
||||||
try {
|
try {
|
||||||
if (CFlag != "") { /* if -C was given */
|
if (CFlag != "") { /* if -C was given */
|
||||||
enforceDie(isValidPath(CFlag), CFlag ~ ": invalid path");
|
enforceDie(CFlag.isValidPath(), CFlag ~ ": invalid path");
|
||||||
configPath = CFlag.expandTilde();
|
configPath = CFlag.expandTilde();
|
||||||
} else {
|
} else {
|
||||||
enforceDie(isValidPath(configPath),
|
enforceDie(configPath.isValidPath(),
|
||||||
configPath ~ ": invalid path");
|
configPath ~ ": invalid path");
|
||||||
|
|
||||||
if (!configPath.exists()) {
|
if (!configPath.exists()) {
|
||||||
mkdirRecurse(configPath.dirName());
|
mkdirRecurse(dirName(configPath));
|
||||||
configPath.write(format!
|
configPath.write(format!
|
||||||
"## Configuration file for esv.
|
"## Configuration file for esv.
|
||||||
|
|
||||||
|
@ -234,7 +239,7 @@ key = %s
|
||||||
if (RFlag) esv.opts.b["include-passage-references"] = false;
|
if (RFlag) esv.opts.b["include-passage-references"] = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
writeln(esv.getPassage(args[1].parseBook(), args[2]));
|
writeln(esv.getPassage(parseBook(args[1]), args[2]));
|
||||||
catch (CurlException e)
|
catch (CurlException e)
|
||||||
die(e.msg);
|
die(e.msg);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue