Tweak CLI a bit more

This commit is contained in:
Starbeamrainbowlabs 2018-09-02 22:28:09 +01:00
parent f6243cb131
commit fd740f5616
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -9,6 +9,7 @@ namespace MarkovGrams
{
public enum Mode
{
None,
Help,
NGrams,
Markov,
@ -19,6 +20,7 @@ namespace MarkovGrams
{
public static int Main(string[] args)
{
Mode mode = Mode.None;
List<string> extras = new List<string>();
StreamReader wordlistSource = new StreamReader(Console.OpenStandardInput());
int order = 3, length = 8, count = 10;
@ -60,14 +62,17 @@ namespace MarkovGrams
case "start-uppercase":
startOnUppercase = true;
break;
case "help":
mode = Mode.Help;
break;
default:
Console.Error.WriteLine($"Error: Unknown option '{args[i]}'.");
return 1;
}
}
Mode mode = extras.Count > 0 ? (Mode)Enum.Parse(typeof(Mode), extras.ShiftAt(0).Replace("markov-w", "weightedmarkov"), true) : Mode.Help;
if(mode != Mode.Help && extras.Count > 0)
mode = (Mode)Enum.Parse(typeof(Mode), extras.ShiftAt(0).Replace("markov-w", "weightedmarkov"), true);
// ------------------------------------------------------------------------------------------
@ -127,6 +132,7 @@ namespace MarkovGrams
Console.WriteLine(" Generate raw unique n-grams");
Console.WriteLine();
Console.WriteLine("Available options:");
Console.WriteLine(" --help Show this message");
Console.WriteLine(" --wordlist {filename} Read the wordlist from the specified filename instead of stdin");
Console.WriteLine(" --order {number} Use the specified order when generating n-grams (default: 3)");
Console.WriteLine(" --length {number} The target length of word to generate (Not available in ngrams mode)");