예제 #1
0
        public static CommandHelp Create(
            Command command,
            IEnumerable <OptionValueProvider> providers = null,
            Filter filter = null)
        {
            ImmutableArray <ArgumentItem> arguments = (command.Arguments.Any())
                ? HelpProvider.GetArgumentItems(command.Arguments, filter)
                : ImmutableArray <ArgumentItem> .Empty;

            ImmutableArray <OptionItem> options = HelpProvider.GetOptionItems(command.Options, filter);

            ImmutableArray <OptionValueList> values = HelpProvider.GetOptionValues(
                command.Options,
                providers ?? ImmutableArray <OptionValueProvider> .Empty,
                filter);

            return(new CommandHelp(command, arguments, options, values));
        }
예제 #2
0
        public void WriteValues(IEnumerable <OptionValueList> optionValues)
        {
            using (IEnumerator <OptionValueList> en = optionValues.GetEnumerator())
            {
                if (en.MoveNext())
                {
                    WriteStartValues();

                    while (true)
                    {
                        WriteTextLine(en.Current.MetaValue);
                        WriteValues(en.Current.Values);

                        if (en.MoveNext())
                        {
                            WriteLine();
                        }
                        else
                        {
                            break;
                        }
                    }

                    WriteEndValues();

                    ImmutableArray <string> expressions = HelpProvider.GetExpressionItems(optionValues);

                    if (!expressions.IsEmpty)
                    {
                        WriteLine();
                        WriteLine("Expression syntax:");

                        foreach (string expression in expressions)
                        {
                            Write(Options.Indent);
                            WriteLine(expression);
                        }
                    }
                }
            }
        }