public ParserResultConfigBackend( ICliSpecDeriverConfig specDeriverConfig, ICliSpecification spec, IParserResult pr, Type t) { if (specDeriverConfig == null) { throw new ArgumentException( $"{nameof( specDeriverConfig )} must not be null", nameof(specDeriverConfig)); } if (spec == null) { throw new ArgumentException($"{nameof( spec )} must not be null", nameof(spec)); } if (pr == null) { throw new ArgumentException($"{nameof( pr )} must not be null", nameof(pr)); } if (t == null) { throw new ArgumentException($"{nameof( t )} must not be null", nameof(t)); } _specDeriverConfig = specDeriverConfig; _spec = spec; _pr = pr; _t = t; }
public ConstraintsCollector( ICliSpecDeriverConfig specDeriverConfig, ICliSpecification spec) { _specDeriverConfig = specDeriverConfig; _spec = spec; }
public TextHelpPrinter( ICliSpecification spec, ITextHelpPrinterConfig conf = null) : base(spec) { _conf = conf ?? Config.New <ITextHelpPrinterConfig>( ); _writer = _conf.TextWriter; }
public InvalidOptionParser(ICliSpecification spec) { _optionPrefix = spec.Config.OptionPrefix( ); _cmpChars = spec.Config.CaseSensitiveOptions ? (Func <char, char, bool>)((c1, c2) => c1 == c2) : (c1, c2) => char.ToUpperInvariant(c1) == char.ToUpperInvariant(c2); }
public ParserResult(ICliSpecification cliSpecification) { CliSpecification = cliSpecification; _options = new List <IOption>( ); _flags = new List <IFlag>( ); _arguments = new Dictionary <IArgument, string>( ); _dynamicArguments = new Dictionary <IArgument, List <string> >( ); }
public ConstraintsProviderContext(ICliSpecification spec, ICliSpecDeriverConfig specDeriverConfig) { _spec = spec; _specDeriverConfig = specDeriverConfig; _itemRules = new Dictionary <string, IRule <IParserResult> >( ); _argumentRules = new Dictionary <string, IRule <IParserResult> >( ); _rules = new List <IRule <IParserResult> >( ); }
public ConflictResolver( ICliConfig config, ICliSpecification spec = null, Func <IList <ISolution <IParserResult> >, ISolution <IParserResult> > userPrompt = null) { _config = config; _rules = spec?.Rules ?? Enumerable.Empty <IRule <IParserResult> >( ); _userPrompt = userPrompt ?? UserPrompt; }
public InvalidFlagParser(ICliSpecification spec) { ICliConfig conf = spec.Config; _flagPrefix = spec.Config.FlagPrefix( ); _cmpChars = conf.CaseSensitiveFlags ? (Func <char, char, bool>)((c1, c2) => c1 == c2) : (c1, c2) => char.ToUpperInvariant(c1) == char.ToUpperInvariant(c2); }
public HelpPrinterBase(ICliSpecification spec) { if (spec == null) { throw new ArgumentException($"{nameof( spec )} must not be null", nameof(spec)); } Spec = spec; }
public CommandLineParser(ICliSpecification spec) { if (spec == null) { throw new NullReferenceException($"{nameof( spec )} must not be null"); } new PolicyChecker(spec.Config).Check(spec); _spec = spec; }
public FlagParser(ICliSpecification spec) { ICliConfig conf = spec.Config; _flags = spec.Flags.ToList( ); _options = spec.Options.Where(o => o.FlagAlias.HasValue).ToList( ); _matches = new List <IItem>( ); _flagPrefix = spec.Config.FlagPrefix( ); _cmpChars = conf.CaseSensitiveFlags ? (Func <char, char, bool>)((c1, c2) => c1 == c2) : (c1, c2) => char.ToUpperInvariant(c1) == char.ToUpperInvariant(c2); }
private ParserResult( ICliSpecification cliSpecification, List <IOption> options, List <IFlag> flags, Dictionary <IArgument, string> arguments, Dictionary <IArgument, List <string> > dynamicArguments) { CliSpecification = cliSpecification; _options = options; _flags = flags; _arguments = arguments; _dynamicArguments = dynamicArguments; }
public void Check(ICliSpecification spec) { IBehaviors context = new BehaviorsBase( ); context.Set(new ConfigBehavior(_config)); foreach (IRule <ICliSpecification> policy in _config.Policies) { IViolation <ICliSpecification> violation = policy.Check(spec, context); if (violation != NonViolation <ICliSpecification> .Instance) { throw new CliPolicyException(policy, violation); } } }
public ParserResultMapper( ICliSpecDeriverConfig specDeriverConfig, ICliSpecification spec) { if (specDeriverConfig == null) { throw new ArgumentException( $"{nameof( specDeriverConfig )} must not be null", nameof(specDeriverConfig)); } if (spec == null) { throw new ArgumentException($"{nameof( spec )} must not be null", nameof(spec)); } _specDeriverConfig = specDeriverConfig; _spec = spec; }
public IEnumerable <IRule <IParserResult> > DeriveRules(ICliSpecification spec) { List <IRule <IParserResult> > rules = new List <IRule <IParserResult> >( ); List <IItem> items = spec.Flags.Cast <IItem>( ).Union(spec.Options).ToList( ); List <IArgument> args = spec.Arguments.Union(items.SelectMany(i => i.Arguments)).ToList( ); foreach (IItem item in items) { rules.AddRange( _itemRuleDerivers.Where(kvp => kvp.Key.IsInstanceOfType(item)) .SelectMany(kvp => kvp.Value(item))); } foreach (IArgument arg in args) { rules.AddRange( _argumentRuleDerivers.Where(kvp => kvp.Key.IsInstanceOfType(arg)) .SelectMany(kvp => kvp.Value(arg))); } return(new ReadOnlyCollection <IRule <IParserResult> >(rules)); }