Esempio n. 1
0
        protected CommandBase(ICommandOutputProvider commandOutputProvider)
        {
            this.commandOutputProvider = commandOutputProvider;

            var options = Options.For("Common options");

            options.Add <bool>("help", "[Optional] Print help for a command", x => printHelp = true);
            options.Add <OutputFormat>("helpOutputFormat=", $"[Optional] Output format for help, valid options are {Enum.GetNames(typeof(OutputFormat)).ReadableJoin("or")}", s => HelpOutputFormat = s);
            formattedOutputInstance = this as ISupportFormattedOutput;
            if (formattedOutputInstance != null)
            {
                options.Add <OutputFormat>("outputFormat=", $"[Optional] Output format, valid options are {Enum.GetNames(typeof(OutputFormat)).ReadableJoin("or")}", s => OutputFormat = s);
            }
            else
            {
                commandOutputProvider.PrintMessages = true;
            }
        }
Esempio n. 2
0
        protected CommandBase(ICommandOutputProvider commandOutputProvider)
        {
            this.commandOutputProvider = commandOutputProvider;

            var options = Options.For("Common options");

            options.Add("help", "[Optional] Print help for a command", x => printHelp = true);
            options.Add("helpOutputFormat=", "[Optional] Output format for help, only valid option is json", SetHelpOutputFormat);
            formattedOutputInstance = this as ISupportFormattedOutput;
            if (formattedOutputInstance != null)
            {
                options.Add("outputFormat=", "[Optional] Output format, only valid option is json",
                            SetOutputFormat);
            }
            else
            {
                commandOutputProvider.PrintMessages = true;
            }
        }