Refactor help text to a separate file

This commit is contained in:
Starbeamrainbowlabs 2018-09-26 20:50:16 +01:00
parent 02e6b2ef8e
commit e006e06685
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 45 additions and 33 deletions

View file

@ -0,0 +1,34 @@
SearchBox
---------
A standalone full-text search engine. Operates on plain text sources.
Usage:
./SearchBox.exe {mode} [options]
Modes:
query Query a pre-existing inverted search index
context Generate a context string similar to a search result on the internet
index Generate a raw index of the source document.
add Add a named document to a search index.
remove Remove a named document from a search index.
update Update a named document in a search index.
Options:
--batch Enters a mode where the operations to process are specified the source (by default stdin; change with --source as usual) - one per line in the format "{filename}|{name}|{tags}" {add}
--format Sets the format of the output. Possible values: text (defaul json, html (context generation only) {query, index, context}
--index Specifies the location of the search index to use {add, remo update}
--name, -n Sets the name of the source document {add, remove, title}
--new-source Specifies the path to the new version of the source document update {update}
--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}
--source, -s Specifies the path to the source document {index, add,context}
--tags Sets the tags to associate with the document. {add, update}
Examples:
Add a file to an index:
./SearchBox.exe add --name "Complex Knots: How do and undo them" <books/complex_knots.txt
Add multiple files to an index in batch mode:
time find sources/ -type f -print0 | xargs -0 -n1 -I{} sh -c 'echo {}\|$(basename -s .md "{}")\|' | ./lib/SearchBox/SearchBox-CLI.exe add --batch --index data/posts.sindex

View file

@ -132,37 +132,7 @@ namespace SearchBoxCLI
private static int HandleHelp()
{
Console.WriteLine("SearchBox");
Console.WriteLine("---------");
Console.WriteLine("A standalone full-text search engine. Operates on plain text sources.");
Console.WriteLine();
Console.WriteLine("Usage:");
Console.WriteLine(" ./SearchBox.exe {mode} [options]");
Console.WriteLine();
Console.WriteLine("Modes:");
Console.WriteLine(" query Query a pre-existing inverted search index");
Console.WriteLine(" context Generate a context string similar to a search result on the internet");
Console.WriteLine(" index Generate a raw index of the source document.");
Console.WriteLine(" add Add a named document to a search index.");
Console.WriteLine(" remove Remove a named document from a search index.");
Console.WriteLine(" update Update a named document in a search index.");
Console.WriteLine();
Console.WriteLine("Options:");
Console.WriteLine(" --batch Enters a mode where the operations to process are specified via the source (by default stdin; change with --source as usual) - one per line in the format \"{filename}|{name}|{tags}\" {add}");
Console.WriteLine(" --format Sets the format of the output. Possible values: text (default), json, html (context generation only) {query, index, context}");
Console.WriteLine(" --index Specifies the location of the search index to use {add, remove, update}");
Console.WriteLine(" --name, -n Sets the name of the source document {add, remove, title}");
Console.WriteLine(" --new-source Specifies the path to the new version of the source document to update {update}");
Console.WriteLine(" --limit Limits the number of results returned, -1 = no limit {query}");
Console.WriteLine(" --offset Skips the specified number of results from the beginning of the results list {query}");
Console.WriteLine(" --old-source Specifies the path to the old version of the source document to update {update}");
Console.WriteLine(" --query Specifies the query string {query, context}");
Console.WriteLine(" --source, -s Specifies the path to the source document {index, add,context}");
Console.WriteLine(" --tags Sets the tags to associate with the document. {add, update}");
Console.WriteLine();
Console.WriteLine("Examples:");
Console.WriteLine(" cat books/complex_knots.txt | ./SearchBox.exe add --name \"Complex Knots: How to do and undo them\"");
Console.WriteLine();
Console.WriteLine(EmbeddedFiles.ReadAllText("SearchBoxCLI.EmbeddedFiles.Help.txt"));
return 1;
}
@ -211,7 +181,7 @@ namespace SearchBoxCLI
File.WriteAllText(SearchIndexFilepath, JsonConvert.SerializeObject(searchBox));
Console.Error.WriteLine($"[Searchbox] [add] {Name} -> {SearchIndexFilepath}");
Console.Error.WriteLine($"[Searchbox] [save] {Name} -> {SearchIndexFilepath}");
return 0;
}

View file

@ -54,5 +54,13 @@
<ItemGroup>
<Folder Include="Utilities\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="EmbeddedFiles\Help.txt" />
</ItemGroup>
<Target Name="AfterBuild">
<Exec Command="chmod -x *" WorkingDirectory="$(OutDir)" />
<Exec Command="chmod +x *.exe" WorkingDirectory="$(OutDir)" />
</Target>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
</Project>