diff --git a/esvsearch.d b/esvsearch.d index 24085ae..17b1c24 100644 --- a/esvsearch.d +++ b/esvsearch.d @@ -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)