public override string ToHelp(OptionArity arity, AbstractType valueType) { StringBuilder help = new StringBuilder(); StringBuilder postfix = new StringBuilder(); if (arity.MinimalOccurs == 0) { postfix.AppendFormat("[={0}]", valueType); } foreach (var sw in Switches) { help.AppendFormat("--{0}{1} ", sw, postfix); } return help.ToString(); }
/// <summary> /// Adds the <see cref="OptionToken"/> to the tokens and sets the context of the tokenizer. /// </summary> /// <param name="tokens">The tokens where the argument will be add.</param> /// <param name="option">The option to add.</param> /// <param name="options">The options and their arities.</param> /// <param name="treatMode">The treat mode.</param> /// <param name="argumentCount">The argument count of the last option.</param> /// <param name="optionArity">The option arity.</param> void AddOption(List<Token> tokens, string option, IDictionary<string, OptionArity> options, ref TreatMode treatMode, ref uint argumentCount, ref OptionArity? optionArity) { if (options.ContainsKey(option)) { AddOption(tokens, option); OptionArity arity = options[option]; if (arity.MinimalOccurs > 0) { treatMode = TreatMode.OptionArgument; argumentCount = 0; optionArity = arity; } } else { AddOption(tokens, option); } }
/// <summary> /// Adds the <see cref="ArgumentToken"/> to the tokens and sets the context of the tokenizer. /// </summary> /// <param name="tokens">The tokens where the argument will be add.</param> /// <param name="argument">The argument to add.</param> /// <param name="treatMode">The treat mode.</param> /// <param name="argumentCount">The argument count of the last option.</param> /// <param name="optionArity">The option arity.</param> void AddArgument(List<Token> tokens, string argument, ref TreatMode treatMode, ref uint argumentCount, ref OptionArity? optionArity) { Debug.Assert(optionArity.HasValue && argumentCount < optionArity.Value.MaximalOccurs, "unexpected option arity"); AddArgument(tokens, argument); argumentCount++; if (argumentCount >= optionArity.Value.MinimalOccurs) { treatMode = TreatMode.None; } if (argumentCount == optionArity.Value.MaximalOccurs) { optionArity = null; argumentCount = uint.MaxValue; } }
public abstract string ToHelp(OptionArity arity, AbstractType valueType);
public string ToHelp(OptionArity arity, AbstractType valueType) { StringBuilder help = new StringBuilder(); help.AppendFormat("{0}, {1}", Short.ToHelp(arity, valueType), Long.ToHelp(arity, valueType) ); return help.ToString(); }
public SwitchesManager(string shortSwitchesString, string longSwitchesString, OptionArity optionArity, AbstractType valueType) { bool intersectionIsEmpty = SwitchesIntersectionIsEmpty(shortSwitchesString, longSwitchesString); if (intersectionIsEmpty) { Short = new ShortSwitches(shortSwitchesString); Long = new LongSwitches(longSwitchesString); } else { throw new DuplicitOptionSwitchException(""); } }
public override string ToHelp(OptionArity arity, AbstractType valueType) { StringBuilder help = new StringBuilder(); foreach (var sw in Switches) { help.AppendFormat("-{0}, ", sw); } return help.ToString(); }