/// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="logger">A logger</param>
        /// <param name="state">The command line state</param>
        /// <param name="serviceProvider">The DI service provider</param>
        public CommandLineService(
            ILogger <CommandLineService <T> > logger,
            CommandLineState state,
            IServiceProvider serviceProvider)
        {
            _logger = logger;
            _state  = state;

            logger.LogDebug(
                "Constructing CommandLineApplication<{type}> with args [{args}]",
                typeof(T).FullName,
                string.Join(",", state.Arguments));

            _application = new CommandLineApplication <T>(state.Console, state.WorkingDirectory);

            _application
            .Conventions
            .UseDefaultConventions()
            .UseConstructorInjection(serviceProvider);

            foreach (var convention in serviceProvider.GetServices <IConvention>())
            {
                _application.Conventions.AddConvention(convention);
            }
        }
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="logger">A logger</param>
        /// <param name="state">The command line state</param>
        /// <param name="serviceProvider">The DI service provider</param>
        public CommandLineService(ILogger <CommandLineService <T> > logger, CommandLineState state,
                                  IServiceProvider serviceProvider)
        {
            this.logger = logger;
            this.state  = state;

            logger.LogDebug("Constructing CommandLineApplication<{type}> with args [{args}]",
                            typeof(T).FullName, String.Join(",", state.Arguments));
            application = new CommandLineApplication <T>();
            application.Conventions
            .UseDefaultConventions()
            .UseConstructorInjection(serviceProvider);
        }
        /// <summary>
        ///     Creates a new instance.
        /// </summary>
        /// <param name="logger">A logger</param>
        /// <param name="state">The command line state</param>
        /// <param name="serviceProvider">The DI service provider</param>
        /// <param name="configure">The delegate to configure the app</param>
        public CommandLineService(
            CommandLineState state,
            IServiceProvider serviceProvider,
            Action <CommandLineApplication> configure,
            ILogger <CommandLineService>?logger = null)
        {
            _logger = logger;
            _state  = state;

            logger?.LogDebug("Constructing CommandLineApplication with args [{args}]", string.Join(",", state.Arguments));
            _application = new CommandLineApplication(state.Console, state.WorkingDirectory);

            _application.Conventions
            .UseDefaultConventions()
            .UseConstructorInjection(serviceProvider);
            foreach (var convention in serviceProvider.GetServices <IConvention>())
            {
                _application.Conventions.AddConvention(convention);
            }

            configure(_application);
        }