Exemple #1
0
        public void AddSection(string header, Action <ICommandPageSectionSettings <TCommand> > sectionSettings)
        {
            var contentRenderer = new PageRenderer();
            var settings        = new CommandPageSectionSettings <TCommand>(_subcommands, _options, contentRenderer);

            sectionSettings(settings);

            PageRenderer.AppendSection(header, contentRenderer.ToString());
        }
Exemple #2
0
        public void AddHelpOption(Action <PageContentOptionSettings> settings = null)
        {
            PageContentOptionSettings contentOptionSettings = null;

            if (settings != null)
            {
                contentOptionSettings = new PageContentOptionSettings();

                settings(contentOptionSettings);
            }

            PageRenderer.AppendOption(PageContentRowFormattingStyle.None,
                                      Constants.HelpOptionString, contentOptionSettings);
        }
        public void AddSubcommand <TSubcommand>(Expression <Func <TCommand, TSubcommand> > propertySelector,
                                                Action <PageContentCommandSettings> settings = null) where TSubcommand : class
        {
            PageContentCommandSettings contentCommandSettings = null;

            if (settings != null)
            {
                contentCommandSettings = new PageContentCommandSettings();

                settings(contentCommandSettings);
            }

            var command = _subcommands.Get(propertySelector);

            if (command == null)
            {
                throw new CommandCouldNotBeFoundException(propertySelector.GetPropertyInfos()[0]);
            }

            PageRenderer.AppendCommand(PageContentRowFormattingStyle.Indent,
                                       command.ToString(), contentCommandSettings);
        }
        public void AddOption <TOption>(Expression <Func <TCommand, TOption> > propertySelector,
                                        Action <PageContentOptionSettings> settings = null)
        {
            PageContentOptionSettings contentOptionSettings = null;

            if (settings != null)
            {
                contentOptionSettings = new PageContentOptionSettings();

                settings(contentOptionSettings);
            }

            var option = _options.Get(propertySelector);

            if (option == null)
            {
                throw new OptionCouldNotBeFoundException(propertySelector.GetPropertyInfos()[0]);
            }

            PageRenderer.AppendOption(PageContentRowFormattingStyle.Indent,
                                      option.ToString(), contentOptionSettings);
        }