esvsearch: split esv search code into separate program
Requires rewiring the build system to accommodate for two executables. Fixes: https://todo.sr.ht/~jeremy/esv/4
This commit is contained in:
parent
de71043ef1
commit
ec8be68b49
6 changed files with 122 additions and 32 deletions
21
esv.d
21
esv.d
|
@ -45,7 +45,6 @@ int lFlag; /* line length */
|
|||
bool lFlagSpecified;
|
||||
bool nFlag, NFlag; /* verse numbers */
|
||||
bool rFlag, RFlag; /* passage references */
|
||||
string sFlag; /* search passages */
|
||||
bool VFlag; /* show version */
|
||||
|
||||
int
|
||||
|
@ -73,7 +72,6 @@ main(string[] args)
|
|||
"l", &onLineLength,
|
||||
"N", &NFlag, "n", &nFlag,
|
||||
"R", &RFlag, "r", &rFlag,
|
||||
"s", &sFlag,
|
||||
"V", &VFlag,
|
||||
);
|
||||
} catch (GetOptException e) {
|
||||
|
@ -85,14 +83,9 @@ main(string[] args)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (sFlag != "") {
|
||||
/* skip argument validation */
|
||||
goto config;
|
||||
}
|
||||
|
||||
if (args.length < 3) {
|
||||
stderr.writefln(
|
||||
"usage: %s [-aFfHhNnRrV] [-c config] [-l length] [-s query] book verses",
|
||||
"usage: %s [-aFfHhNnRrV] [-c config] [-l length] book verses",
|
||||
baseName(args[0]));
|
||||
return 1;
|
||||
}
|
||||
|
@ -134,8 +127,6 @@ key = %s
|
|||
die(e.msg);
|
||||
}
|
||||
|
||||
enforceDie(!(aFlag && sFlag), "cannot specify both -a and -s flags");
|
||||
|
||||
apiKey = ini["api"].key("key");
|
||||
enforceDie(apiKey != null,
|
||||
"API key not present in configuration file; cannot proceed");
|
||||
|
@ -168,16 +159,6 @@ key = %s
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (sFlag) {
|
||||
try
|
||||
writeln(esv.searchFormat(sFlag));
|
||||
catch (ESVException)
|
||||
die("no results for search");
|
||||
catch (CurlException e)
|
||||
die(e.msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
esv.extraParameters = ini["api"].key("parameters", "");
|
||||
|
||||
/* Get [passage] keys */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue