From 1ed36260f351324bea6cf0a82fe7493a0070e2d9 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 25 Jun 2024 16:20:40 +1200 Subject: [PATCH] esv: remove bad use of UFCS --- esv.d | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/esv.d b/esv.d index a3adea0..e3bbb64 100644 --- a/esv.d +++ b/esv.d @@ -93,10 +93,12 @@ main(string[] args) "V", &VFlag, ); } catch (GetOptException e) { + string opt = extractOpt(e); + enforceDie(!e.msg.startsWith("Unrecognized option"), - "unknown option " ~ e.extractOpt()); + "unknown option " ~ opt); enforceDie(!e.msg.startsWith("Missing value for argument"), - "missing argument for option " ~ e.extractOpt()); + "missing argument for option " ~ opt); die(e.msg); /* catch-all */ } @@ -112,11 +114,13 @@ main(string[] args) } 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; } - enforceDie(bookValid(args[1].parseBook()), + enforceDie(bookValid(parseBook(args[1])), "book '%s' does not exist", args[1]); enforceDie(verseValid(args[2]), "invalid verse format '%s'", args[2]); @@ -124,17 +128,18 @@ main(string[] args) /* determine configuration file: options take first priority, * then environment variables, and then the default path */ config: - configPath = environment.get(cf.configEnv, cf.configPath).expandTilde(); + configPath = environment.get(cf.configEnv, cf.configPath) + .expandTilde(); try { if (CFlag != "") { /* if -C was given */ - enforceDie(isValidPath(CFlag), CFlag ~ ": invalid path"); + enforceDie(CFlag.isValidPath(), CFlag ~ ": invalid path"); configPath = CFlag.expandTilde(); } else { - enforceDie(isValidPath(configPath), + enforceDie(configPath.isValidPath(), configPath ~ ": invalid path"); if (!configPath.exists()) { - mkdirRecurse(configPath.dirName()); + mkdirRecurse(dirName(configPath)); configPath.write(format! "## Configuration file for esv. @@ -234,7 +239,7 @@ key = %s if (RFlag) esv.opts.b["include-passage-references"] = false; try - writeln(esv.getPassage(args[1].parseBook(), args[2])); + writeln(esv.getPassage(parseBook(args[1]), args[2])); catch (CurlException e) die(e.msg); return 0;