internal CommandLineApplication(
            CommandLineApplication?parent,
            IHelpTextGenerator helpTextGenerator,
            CommandLineContext context)
        {
            _context                = context ?? throw new ArgumentNullException(nameof(context));
            Parent                  = parent;
            Options                 = new List <CommandOption>();
            Arguments               = new List <CommandArgument>();
            Commands                = new List <CommandLineApplication>();
            RemainingArguments      = new List <string>();
            _helpTextGenerator      = helpTextGenerator ?? throw new ArgumentNullException(nameof(helpTextGenerator));
            _handler                = DefaultAction;
            _validationErrorHandler = DefaultValidationErrorHandler;
            Out   = context.Console.Out;
            Error = context.Console.Error;
            SetContext(context);
            _services           = new Lazy <IServiceProvider>(() => new ServiceProvider(this));
            ValueParsers        = parent?.ValueParsers ?? new ValueParserProvider();
            _parserConfig       = new ParserConfig();
            _clusterOptions     = parent?._clusterOptions;
            UsePagerForHelpText = parent?.UsePagerForHelpText ?? false;

            _conventionContext = CreateConventionContext();

            if (Parent != null)
            {
                foreach (var convention in Parent._conventions)
                {
                    Conventions.AddConvention(convention);
                }
            }
        }
        internal CommandLineApplication(CommandLineApplication parent,
                                        IHelpTextGenerator helpTextGenerator,
                                        CommandLineContext context,
                                        bool throwOnUnexpectedArg)
        {
            _context = context ?? throw new ArgumentNullException(nameof(context));
            Parent   = parent;
            ThrowOnUnexpectedArgument = throwOnUnexpectedArg;
            Options                = new List <CommandOption>();
            Arguments              = new List <CommandArgument>();
            Commands               = new List <CommandLineApplication>();
            RemainingArguments     = new List <string>();
            HelpTextGenerator      = helpTextGenerator;
            Invoke                 = () => 0;
            ValidationErrorHandler = DefaultValidationErrorHandler;
            SetContext(context);
            _services           = new Lazy <IServiceProvider>(() => new ServiceProvider(this));
            ValueParsers        = parent?.ValueParsers ?? new ValueParserProvider();
            _clusterOptions     = parent?._clusterOptions;
            UsePagerForHelpText = parent?.UsePagerForHelpText ?? true;

            _conventionContext = CreateConventionContext();

            if (Parent != null)
            {
                foreach (var convention in Parent._conventions)
                {
                    Conventions.AddConvention(convention);
                }
            }
        }
예제 #3
0
        internal CommandLineApplication(CommandLineApplication parent,
                                        IHelpTextGenerator helpTextGenerator,
                                        CommandLineContext context,
                                        bool throwOnUnexpectedArg)
        {
            _context = context ?? throw new ArgumentNullException(nameof(context));
            Parent   = parent;
            ThrowOnUnexpectedArgument = throwOnUnexpectedArg;
            Options                = new List <CommandOption>();
            Arguments              = new List <CommandArgument>();
            Commands               = new List <CommandLineApplication>();
            RemainingArguments     = new List <string>();
            HelpTextGenerator      = helpTextGenerator;
            Invoke                 = () => 0;
            ValidationErrorHandler = DefaultValidationErrorHandler;
            SetContext(context);

            _conventionContext = CreateConventionContext();

            if (Parent != null)
            {
                foreach (var convention in Parent._conventions)
                {
                    Conventions.AddConvention(convention);
                }
            }
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of <see cref="RootCommandLineApplication"/>.
 /// </summary>
 public RootCommandLineApplication(IHelpTextGenerator helpTextGenerator,
                                   IConsole console,
                                   IHostingEnvironment environment,
                                   IConfiguration configuration)
     : base(helpTextGenerator,
            console,
            environment.WorkingDirectory,
            !Boolean.Parse(configuration[HostDefaults.AllowUnknownArgumentsKey] ?? Boolean.FalseString))
 {
 }
 internal CommandLineApplication(IHelpTextGenerator helpTextGenerator, CommandLineContext context, bool throwOnUnexpectedArg)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
     ThrowOnUnexpectedArgument = throwOnUnexpectedArg;
     Options                = new List <CommandOption>();
     Arguments              = new List <CommandArgument>();
     Commands               = new List <CommandLineApplication>();
     RemainingArguments     = new List <string>();
     HelpTextGenerator      = helpTextGenerator;
     Invoke                 = () => 0;
     ValidationErrorHandler = DefaultValidationErrorHandler;
     SetContext(context);
 }
예제 #6
0
        /// <summary>
        /// Initializes a new instance of <see cref="CommandLineApplication"/>.
        /// </summary>
        /// <param name="helpTextGenerator">The help text generator to use.</param>
        /// <param name="console">The console implementation to use.</param>
        /// <param name="workingDirectory">The current working directory.</param>
        /// <param name="throwOnUnexpectedArg">Initial value for <see cref="ThrowOnUnexpectedArgument"/>.</param>
        public CommandLineApplication(IHelpTextGenerator helpTextGenerator, IConsole console, string workingDirectory, bool throwOnUnexpectedArg)
        {
            if (console == null)
            {
                throw new ArgumentNullException(nameof(console));
            }

            if (string.IsNullOrEmpty(workingDirectory))
            {
                throw new ArgumentException("Argument must not be null or empty", nameof(workingDirectory));
            }

            ThrowOnUnexpectedArgument = throwOnUnexpectedArg;
            WorkingDirectory          = workingDirectory;
            Options                = new List <CommandOption>();
            Arguments              = new List <CommandArgument>();
            Commands               = new List <CommandLineApplication>();
            RemainingArguments     = new List <string>();
            HelpTextGenerator      = helpTextGenerator;
            Invoke                 = () => 0;
            ValidationErrorHandler = DefaultValidationErrorHandler;
            SetConsole(console);
        }
 /// <summary>
 /// Initializes a new instance of <see cref="CommandLineApplication"/>.
 /// </summary>
 /// <param name="helpTextGenerator">The help text generator to use.</param>
 /// <param name="console">The console implementation to use.</param>
 /// <param name="workingDirectory">The current working directory.</param>
 public CommandLineApplication(IHelpTextGenerator helpTextGenerator, IConsole console, string workingDirectory)
     : this(null, helpTextGenerator, new DefaultCommandLineContext(console, workingDirectory))
 {
 }
예제 #8
0
 public CommandLineApplication(IHelpTextGenerator helpTextGenerator, IConsole console, string workingDirectory, bool throwOnUnexpectedArg)
     : this(null, helpTextGenerator, new DefaultCommandLineContext(console, workingDirectory), throwOnUnexpectedArg)
 {
 }
 /// <inheritdoc />
 protected CommandLineApplicationPlus(IHelpTextGenerator helpTextGenerator, CommandLineConsoleInterface console, ICommandLineConsoleLogger consoleLogger, string workingDirectory) : base(helpTextGenerator, console, workingDirectory)
 {
     Console       = console;
     ConsoleLogger = consoleLogger;
 }
 /// <summary>
 /// Initializes a new instance of <see cref="CommandLineApplication"/>.
 /// </summary>
 /// <param name="helpTextGenerator">The help text generator to use.</param>
 /// <param name="console">The console implementation to use.</param>
 /// <param name="workingDirectory">The current working directory.</param>
 /// <param name="throwOnUnexpectedArg">Initial value for <see cref="CommandLineApplication.ThrowOnUnexpectedArgument"/>.</param>
 public CommandLineApplication(IHelpTextGenerator helpTextGenerator, IConsole console, string workingDirectory, bool throwOnUnexpectedArg)
     : base(helpTextGenerator, console, workingDirectory, throwOnUnexpectedArg)
 {
     Initialize();
 }
 /// <summary>
 /// <para>
 /// This constructor is obsolete and will be removed in a future version.
 /// The recommended replacement is <see cref="CommandLineApplication{TModel}(IHelpTextGenerator, IConsole, string)" />
 /// </para>
 /// <para>
 /// Initializes a new instance of <see cref="CommandLineApplication{TModel}"/>.
 /// </para>
 /// </summary>
 /// <param name="helpTextGenerator">The help text generator to use.</param>
 /// <param name="console">The console implementation to use.</param>
 /// <param name="workingDirectory">The current working directory.</param>
 public CommandLineApplication(IHelpTextGenerator helpTextGenerator, IConsole console, string workingDirectory)
     : base(helpTextGenerator, console, workingDirectory)
 {
     Initialize();
 }