Compare commits
2 Commits
b24f573eb9
...
53e4403356
Author | SHA1 | Date |
---|---|---|
Starbeamrainbowlabs | 53e4403356 | |
Starbeamrainbowlabs | c450051218 |
|
@ -37,7 +37,7 @@ namespace SearchBoxCLI
|
||||||
private static string SearchIndexFilepath = string.Empty;
|
private static string SearchIndexFilepath = string.Empty;
|
||||||
private static TextReader Source = Console.In;
|
private static TextReader Source = Console.In;
|
||||||
private static TextReader SourceOld = null, SourceNew = null;
|
private static TextReader SourceOld = null, SourceNew = null;
|
||||||
private static OutputModes OutputMode = OutputModes.Json;
|
private static OutputModes OutputMode = OutputModes.Text;
|
||||||
|
|
||||||
public static int Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
|
@ -82,6 +82,10 @@ namespace SearchBoxCLI
|
||||||
SearchIndexFilepath = args[++i];
|
SearchIndexFilepath = args[++i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "format":
|
||||||
|
OutputMode = (OutputModes)Enum.Parse(typeof(OutputModes), args[++i], true);
|
||||||
|
break;
|
||||||
|
|
||||||
case "help":
|
case "help":
|
||||||
return HandleHelp();
|
return HandleHelp();
|
||||||
|
|
||||||
|
@ -122,6 +126,7 @@ namespace SearchBoxCLI
|
||||||
Console.WriteLine(" update Update a named document in a search index.");
|
Console.WriteLine(" update Update a named document in a search index.");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine("Options:");
|
Console.WriteLine("Options:");
|
||||||
|
Console.WriteLine(" --format Sets the format of the output. Possible values: text (default), json");
|
||||||
Console.WriteLine(" --source, -s Specifies the path to the source document {index, add}");
|
Console.WriteLine(" --source, -s Specifies the path to the source document {index, add}");
|
||||||
Console.WriteLine(" --old-source Specifies the path to the old version of the source document to update {update}");
|
Console.WriteLine(" --old-source Specifies the path to the old version of the source document to update {update}");
|
||||||
Console.WriteLine(" --new-source Specifies the path to the new version of the source document to update {update}");
|
Console.WriteLine(" --new-source Specifies the path to the new version of the source document to update {update}");
|
||||||
|
|
|
@ -124,7 +124,7 @@ namespace LibSearchBox
|
||||||
});
|
});
|
||||||
|
|
||||||
List<SearchResult> results = new List<SearchResult>(resultsRaw.AsEnumerable());
|
List<SearchResult> results = new List<SearchResult>(resultsRaw.AsEnumerable());
|
||||||
results.OrderBy((SearchResult result) => result.Rank);
|
results.Sort((SearchResult a, SearchResult b) => (int)Math.Round(b.Rank - a.Rank));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,9 @@ namespace LibSearchBox
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
result.AppendLine($"{Rank.ToString().PadLeft(5)}: {PageName}");
|
result.AppendLine($"{PageName} - ({Rank} points)");
|
||||||
result.Append($" {string.Join(", ", Offsets.Select((SearchOffset nextOffset) => $"{nextOffset.Term} @ {nextOffset.Offset}"))}");
|
result.Append($" {string.Join(", ", Offsets.Select((SearchOffset nextOffset) => $"{nextOffset.Offset}:{nextOffset.Term}"))}");
|
||||||
return base.ToString();
|
return result.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue