Ejemplo n.º 1
0
        private bool WriteOptionPrototype(TextWriter o, Option p, ref int written)
        {
            string[] names            = p.Names;
            int      nextOptionIndex1 = OptionSet.GetNextOptionIndex(names, 0);

            if (nextOptionIndex1 == names.Length)
            {
                return(false);
            }
            if (names[nextOptionIndex1].Length == 1)
            {
                OptionSet.Write(o, ref written, "  -");
                OptionSet.Write(o, ref written, names[0]);
            }
            else
            {
                OptionSet.Write(o, ref written, "      --");
                OptionSet.Write(o, ref written, names[0]);
            }
            for (int nextOptionIndex2 = OptionSet.GetNextOptionIndex(names, nextOptionIndex1 + 1); nextOptionIndex2 < names.Length; nextOptionIndex2 = OptionSet.GetNextOptionIndex(names, nextOptionIndex2 + 1))
            {
                OptionSet.Write(o, ref written, ", ");
                OptionSet.Write(o, ref written, names[nextOptionIndex2].Length == 1 ? "-" : "--");
                OptionSet.Write(o, ref written, names[nextOptionIndex2]);
            }
            if (p.OptionValueType == OptionValueType.Optional || p.OptionValueType == OptionValueType.Required)
            {
                if (p.OptionValueType == OptionValueType.Optional)
                {
                    OptionSet.Write(o, ref written, this.localizer("["));
                }
                OptionSet.Write(o, ref written, this.localizer("=" + OptionSet.GetArgumentName(0, p.MaxValueCount, p.Description)));
                string str = p.ValueSeparators == null || p.ValueSeparators.Length <= 0 ? " " : p.ValueSeparators[0];
                for (int index = 1; index < p.MaxValueCount; ++index)
                {
                    OptionSet.Write(o, ref written, this.localizer(str + OptionSet.GetArgumentName(index, p.MaxValueCount, p.Description)));
                }
                if (p.OptionValueType == OptionValueType.Optional)
                {
                    OptionSet.Write(o, ref written, this.localizer("]"));
                }
            }
            return(true);
        }