/// <summary> /// Tell the parser what to look for. Specifying the names, short /// and long command strings that should be added to the parser's result. /// </summary> static async Task <ComparisonOptions> BuildComparisonOptions(string[] args) { var flagsParser = new CommandFlagsParser() .AddFlag(CommandFlagProperties.SearchOptionFlag) .AddFlag(CommandFlagProperties.StrictnessFlag) .AddFlag(CommandFlagProperties.BiasFactorFlag); var flags = await flagsParser.Parse(args); var comparerOptions = new ComparisonOptionsBuilder().BuildFromFlags(flags, new None <ComparisonOptions>()); return(comparerOptions); }
/// <summary> /// Change the options that the programs performs comparisons with. The /// user will be prompted for each option to overwrite, one at a time. /// </summary> /// <param name="currentOptions">The options comparisons are currently using.</param> /// <returns>The new options future comparisons should run with.</returns> static ComparisonOptions OverwriteComparisonOptions(ComparisonOptions currentOptions) { Console.WriteLine("Enter New Option Values"); Console.WriteLine("Leave an option blank to keep its current value."); var flagsToChange = new Dictionary <string, string>(); // Ask for how deep to look in the directory. If the user does not input a value, // we keep the current setting. Console.WriteLine("Directory Level: "); var newDirectoryLevel = Console.ReadLine(); if (!string.IsNullOrEmpty(newDirectoryLevel)) { flagsToChange[CommandFlagProperties.SearchOptionFlag.Name] = newDirectoryLevel; } // Ask for the new strictness level to use. No value means we keep the current // value we have. Console.WriteLine("Strictness Level: "); var newStrictness = Console.ReadLine(); if (!string.IsNullOrEmpty(newStrictness)) { flagsToChange[CommandFlagProperties.StrictnessFlag.Name] = newStrictness; } // Ask for the new bias factor. The current setting is kept if the user gives // no new value. Console.WriteLine("Bias Factor: "); var newBiasFactor = Console.ReadLine(); if (!string.IsNullOrEmpty(newBiasFactor)) { flagsToChange[CommandFlagProperties.BiasFactorFlag.Name] = newBiasFactor; } // Build a new `ComparisonOptions` object, using the newly created dictionary // from the user's input. var updatedOptions = new ComparisonOptionsBuilder() .BuildFromFlags(flagsToChange, new Some <ComparisonOptions>(currentOptions)); return(updatedOptions); }