コード例 #1
0
        /// <summary>
        /// Adds an interactive mode to the application (enabled with [interactive] directive or `interactive` command).
        /// By default this adds [interactive], [default], [>], [.], and [..], as well as `interactive` command and advanced command input.
        /// </summary>
        public static CliApplicationBuilder UseInteractiveMode(this CliApplicationBuilder builder,
                                                               bool asStartup = false,
                                                               Action <InteractiveModeOptions>?options        = null,
                                                               InteractiveModeBuilderSettings?builderSettings = null)
        {
            builderSettings ??= new InteractiveModeBuilderSettings();

            builder.RegisterMode <InteractiveMode>(asStartup);

            options ??= (InteractiveModeOptions cfg) => { };
            builder.ConfigureServices((IServiceCollection sc) => sc.Configure(options));

            builder.AddDirective <DefaultDirective>();

            if (builderSettings.AddInteractiveCommand)
            {
                builder.AddCommand <InteractiveCommand>();
            }

            if (builderSettings.AddInteractiveDirective)
            {
                builder.AddDirective <InteractiveDirective>();
            }

            if (builderSettings.AddScopeDirectives)
            {
                builder.AddDirective <ScopeDirective>();
                builder.AddDirective <ScopeResetDirective>();
                builder.AddDirective <ScopeUpDirective>();
            }

            return(builder);
        }
コード例 #2
0
        /// <summary>
        /// Adds a direct mode to the application.
        /// </summary>
        public static CliApplicationBuilder UseDirectMode(this CliApplicationBuilder builder,
                                                          bool asStartup = false)
        {
            builder.RegisterMode <DirectMode>(asStartup);

            return(builder);
        }