Example #1
0
        private static void AddHelpOption(BuildEvents.CommandCreatedEventArgs args)
        {
            if (args.CommandBuilder.Command.ContainsArgumentNode(Constants.HelpOptionName))
            {
                return;
            }

            var appSettingsHelp = args.CommandContext.AppConfig.AppSettings.Help;

            var option = new Option(Constants.HelpOptionName, 'h',
                                    TypeInfo.Flag, ArgumentArity.Zero,
                                    aliases: new[] { "?" },
                                    definitionSource: typeof(HelpMiddleware).FullName)
            {
                Description        = "Show help information",
                IsMiddlewareOption = true,
                ShowInHelp         = appSettingsHelp.PrintHelpOption
            };

            args.CommandBuilder.AddArgument(option);
        }
        private static void AddVersionOption(BuildEvents.CommandCreatedEventArgs args)
        {
            if (!args.CommandBuilder.Command.IsRootCommand())
            {
                return;
            }

            if (args.CommandBuilder.Command.ContainsArgumentNode(Resources.A.Command_version))
            {
                return;
            }

            var option = new Option(VersionOptionName, 'v',
                                    TypeInfo.Flag, ArgumentArity.Zero, BooleanMode.Implicit,
                                    definitionSource: typeof(VersionMiddleware).FullName)
            {
                Description        = Resources.A.Command_version_description,
                IsMiddlewareOption = true
            };

            args.CommandBuilder.AddArgument(option);
        }
Example #3
0
        private static void AddHelpOption(BuildEvents.CommandCreatedEventArgs args)
        {
            var helpOptionName = Resources.A.Command_help;

            if (args.CommandBuilder.Command.ContainsArgumentNode(helpOptionName))
            {
                return;
            }

            var appSettingsHelp = args.CommandContext.AppConfig.AppSettings.Help;

            var option = new Option(helpOptionName, 'h',
                                    TypeInfo.Flag, ArgumentArity.Zero, BooleanMode.Implicit,
                                    aliases: new[] { "?" },
                                    definitionSource: typeof(HelpMiddleware).FullName)
            {
                Description        = Resources.A.Command_help_description,
                IsMiddlewareOption = true,
                Hidden             = !appSettingsHelp.PrintHelpOption
            };

            args.CommandBuilder.AddArgument(option);
        }