private static IConfigurationBuilder AddJ4JCommandLineDefault(this IConfigurationBuilder builder, CommandLineOperatingSystems opSys, out OptionCollection?options, out CommandLineSource?cmdLineSource, ITextConverters?converters = null, IJ4JLogger?logger = null, params ICleanupTokens[] cleanupTokens) { converters ??= new TextConverters(); var textComparison = opSys switch { CommandLineOperatingSystems.Windows => StringComparison.OrdinalIgnoreCase, CommandLineOperatingSystems.Linux => StringComparison.Ordinal, _ => throw new InvalidEnumArgumentException($"Unsupported {nameof( CommandLineOperatingSystems )} value '{opSys}'") }; var lexicalElements = opSys switch { CommandLineOperatingSystems.Windows => (ILexicalElements) new WindowsLexicalElements(logger), CommandLineOperatingSystems.Linux => (ILexicalElements) new LinuxLexicalElements(logger), _ => throw new InvalidEnumArgumentException($"Unsupported {nameof( CommandLineOperatingSystems )} value '{opSys}'") }; options = new OptionCollection(textComparison, converters, logger); var optionsGenerator = new OptionsGenerator(options, textComparison, logger); var parsingTable = new ParsingTable(optionsGenerator, logger); var tokenizer = new Tokenizer(lexicalElements); return(builder.AddJ4JCommandLine(new Parser(options, parsingTable, tokenizer, logger), out cmdLineSource, logger, cleanupTokens)); } } }
public static ParsingTable GetLinuxDefault(IJ4JLogger?logger = null) => new ParsingTable(OptionsGenerator.GetLinuxDefault(logger), logger);