Add stdin support to --query parameter

This commit is contained in:
Starbeamrainbowlabs 2018-09-27 20:56:55 +01:00
parent e006e06685
commit 3b59dd7c0a
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
2 changed files with 6 additions and 1 deletions

View File

@ -22,7 +22,7 @@ Options:
--limit Limits the number of results returned, -1 = no limit {query}
--offset Skips the specified number of results from the beginning of results list {query}
--old-source Specifies the path to the old version of the source document update {update}
--query Specifies the query string {query, context}
--query Specifies the query string - set to "-" to use the first line of stdin instead {query, context}
--source, -s Specifies the path to the source document {index, add,context}
--tags Sets the tags to associate with the document. {add, update}

View File

@ -222,6 +222,11 @@ namespace SearchBoxCLI
return 1;
}
// Use the first line of stdin instead of the actual query string if "-" is specified
if (Query == "-") {
Query = Console.ReadLine().Trim();
}
SearchBox searchBox = JsonConvert.DeserializeObject<SearchBox>(
File.ReadAllText(SearchIndexFilepath)
);