Пример #1
0
        public static ICommand AddHelp(this ObjectCommand command)
        {
            var help = new HelpOption();

            command.CommandSource = command.CommandSource.Concat(new ObjectCommandSource(
                                                                     null,
                                                                     ObjectProvider.Create(help.GetType(), () => help)
                                                                     ));
            help.Command = command;
            return(command);
        }
Пример #2
0
        public static Maybe <ICommand> Create(ICommand parent, IObjectProvider containingObject, MethodInfo method, IEnumerable <IOption> inheritedOptions)
        {
            if (inheritedOptions == null)
            {
                throw new ArgumentNullException(nameof(inheritedOptions));
            }

            return(method
                   .GetUsage()
                   .Select(usage =>
            {
                var help = new HelpOption();
                var helpCommand = new ObjectCommandSource(null, ObjectProvider.Create(help));

                var c = new MethodCommand(parent, containingObject, method, helpCommand.Options.Concat(inheritedOptions));

                help.Command = c;
                return (ICommand)c;
            }));
        }