esvsearch: add -e option for exact matches
This commit is contained in:
parent
140376887a
commit
1d33403355
1 changed files with 7 additions and 0 deletions
|
@ -35,6 +35,7 @@ import cf = config;
|
|||
@safe:
|
||||
|
||||
string cFlag; /* config path */
|
||||
bool eFlag; /* exact matches */
|
||||
bool VFlag; /* show version */
|
||||
|
||||
int
|
||||
|
@ -57,6 +58,7 @@ main(string[] args)
|
|||
config.bundling,
|
||||
config.caseSensitive,
|
||||
"c", &cFlag,
|
||||
"e", &eFlag,
|
||||
"V", &VFlag,
|
||||
);
|
||||
} catch (GetOptException e) {
|
||||
|
@ -75,6 +77,7 @@ main(string[] args)
|
|||
}
|
||||
|
||||
query = args[1].dup();
|
||||
query = eFlag ? `"` ~ query ~ `"` : query;
|
||||
|
||||
/* determine configuration file: options take first priority,
|
||||
* then environment variables, and then the default path */
|
||||
|
@ -102,6 +105,10 @@ main(string[] args)
|
|||
|
||||
esv = ESVApi(apiKey);
|
||||
|
||||
foreach (char ch; args[1]) {
|
||||
enforceDie(ch != '"', "query is invalid; remove any double quotes");
|
||||
}
|
||||
|
||||
try
|
||||
writeln(esv.searchFormat(query));
|
||||
catch (ESVException)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue