コード例 #1
0
ファイル: Program.cs プロジェクト: rasmus-z/snitch
        public static async Task <int> Run(IConsole console, string[] args)
        {
            var app = new CommandApp(new TypeRegistrar(console));

            app.SetDefaultCommand <AnalyzeCommand>();
            app.Configure(config =>
            {
                config.SetApplicationName("snitch");

                config.UseStrictParsing();
                config.ValidateExamples();

                config.AddExample(new[] { "Project.csproj" });
                config.AddExample(new[] { "Project.csproj", "-e", "Foo", "-e", "Bar" });
                config.AddExample(new[] { "Project.csproj", "--tfm", "net462" });
                config.AddExample(new[] { "Project.csproj", "--tfm", "net462", "--strict" });

                config.AddExample(new[] { "Solution.sln" });
                config.AddExample(new[] { "Solution.sln", "-e", "Foo", "-e", "Bar" });
                config.AddExample(new[] { "Solution.sln", "--tfm", "net462" });
                config.AddExample(new[] { "Solution.sln", "--tfm", "net462", "--strict" });

                config.AddCommand <VersionCommand>("version");
            });

            return(await app.RunAsync(args));
        }
コード例 #2
0
        public static async Task <int> Main(string[] args)
        {
            var app = new CommandApp();

            app.SetDefaultCommand <ScoreCommand>();
            app.Configure(config =>
            {
                config.SetApplicationName("score");
                config.ValidateExamples();
                config.AddExample(new[] { "<PACKAGE_NAME>", "<VERSION>" });
            });

            return(await app.RunAsync(args));
        }
コード例 #3
0
ファイル: Startup.cs プロジェクト: agc93/project-sicario
        internal static CommandApp GetApp()
        {
            var level = GetLogLevel();
            var app   = new CommandApp(new DependencyInjectionRegistrar(GetServices()));

            app.SetDefaultCommand <BuildCommand>();
            app.Configure(c =>
            {
                if (level < LogLevel.Information)
                {
                    c.PropagateExceptions();
                }
                // c.PropagateExceptions();
                c.AddCommand <BuildCommand>("build");
                c.AddCommand <PresetPackCommand>("preset-pack");
            });
            return(app);
        }
コード例 #4
0
        static int Main(string[] args)
        {
            var services = new ServiceCollection();

            services.AddSingleton <GreetingService>();
            // add extra services to the container here
            using var registrar = new DependencyInjectionRegistrar(services);
            var app = new CommandApp(registrar);

            app.SetDefaultCommand <InfoCommand>();
            app.Configure(config =>
            {
                config.AddCommand <InfoCommand>("greet");
                // configure your commands as per usual
                // commands are automatically added to the container
            });
            return(app.Run(args));
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: agc93/husk
        static int Main(string[] args)
        {
            var services = new ServiceCollection()
                           .AddSingleton <IShellService, BasicShellService>()
                           .AddSingleton <IShellDiscoveryService, DefaultShellDiscoveryService>()
                           .AddSingleton <IConfigService, YamlConfigService>();
            var app = new CommandApp(new ServiceRegistrar(services));

            app.Configure(config => {
                config.AddBranch <ShellSettings>("config", branch => {
                    branch.SetDescription("Extra commands for working with the Husk configuration file");
                    branch.AddCommand <Config.ConfigCreateCommand>("create");
                    branch.AddCommand <Config.ConfigListCommand>("list");
                    branch.AddCommand <Config.ConfigDeleteCommand>("delete");
                });
                config.AddCommand <MenuCommand>("menu");
            });
            app.SetDefaultCommand <MenuCommand>();
            return(app.Run(args));
        }
コード例 #6
0
        static async Task <int> Main(string[] args)
        {
            var services = new ServiceCollection();

            services.AddSingleton <IOptionsPrompt <BuildCommand.Settings>, SharpromptOptionsPrompt>();
            services.AddSingleton <IFileService, FileService>();
            services.AddSingleton <IIdentifierParser, PortraitParser>();
            services.AddSingleton <IIdentifierParser, CrosshairParser>();
            services.AddSingleton <IIdentifierParser, SkinParser>();
            services.AddSingleton <IIdentifierParser, WeaponParser>();
            services.AddSingleton <IIdentifierParser, EffectsParser>();
            services.AddSingleton <IIdentifierParser, CanopyParser>();
            services.AddSingleton <IIdentifierParser, EmblemParser>();
            services.AddSingleton <IIdentifierParser, CockpitParser>();
            services.AddSingleton <ArchiveService>();
            services.AddUnPak();
            services.AddSingleton <AppInfoService>();
            services.AddSingleton <ParserService>();
            services.AddSingleton <ModInstaller.ImageLocatorService>();
            services.AddLogging(logging => {
                logging.SetMinimumLevel(LogLevel.Trace);
                logging.AddInlineSpectreConsole(c => {
                    c.LogLevel = GetLogLevel();
                });
            });
            var app = new CommandApp(new DependencyInjectionRegistrar(services));

            app.SetDefaultCommand <BuildCommand>();
            app.Configure(c => {
                c.SetApplicationName("acmi");
                c.AddCommand <BuildCommand>("build");
                c.AddCommand <PackCommand>("zip");
                c.AddCommand <InfoCommand>("info");
                c.AddExample(new[] { "build" });
                c.AddExample(new[] { "build", "./ModPackFiles" });
                c.AddExample(new[] { "build", "--author", "agc93", "--title", "\"My Awesome Skin Pack\"", "--version", "1.0.0" });
            });
            return(await app.RunAsync(args));
        }
コード例 #7
0
        public void Should_Be_Able_To_Set_The_Default_Command()
        {
            // Given
            var resolver = new FakeTypeResolver();
            var settings = new DogSettings();

            resolver.Register(settings);

            var app = new CommandApp(new FakeTypeRegistrar(resolver));

            app.SetDefaultCommand <DogCommand>();

            // When
            var result = app.Run(new[] { "4", "12", "--good-boy", "--name", "Rufus" });

            // Then
            result.ShouldBe(0);
            settings.Legs.ShouldBe(4);
            settings.Age.ShouldBe(12);
            settings.GoodBoy.ShouldBe(true);
            settings.Name.ShouldBe("Rufus");
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: davidcaldas/omnia-cli
        private static int Main(string[] args)
        {
            var configuration = CreateConfigurationRoot();

            var services = new ServiceCollection()
                           .AddScoped <IAuthenticationProvider, AuthenticationProvider>()
                           .Configure <AppSettings>(configuration);

            services
            .AddHttpClient <IApiClient, ApiClient>();

            JsonConvert.DefaultSettings = () => new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                Converters        = new List <JsonConverter>
                {
                    new StringEnumConverter()
                }
            };

            var serviceProvider = services.BuildServiceProvider();

            var registrar = new TypeRegistrar(services);

            var app = new CommandApp(registrar);

            app.SetDefaultCommand <Commands.AppCommand>();
            app.Configure(config =>
            {
                config.AddBranch("subscriptions", subscription =>
                {
                    subscription.SetDescription("Commands to configure subscriptions.");
                    subscription.AddCommand <AddCommand>("add");
                    subscription.AddCommand <ListCommand>("list");
                    subscription.AddCommand <RemoveCommand>("remove");
                });

                config.AddBranch("security", security =>
                {
                    security.SetDescription("Commands related to Tenant Security.");
                    security.AddBranch("users", users =>
                    {
                        users.SetDescription("Commands related to Tenant Users security.");
                        users.AddCommand <Commands.Security.Users.AddCommand>("add");
                        users.AddCommand <Commands.Security.Users.ImportCommand>("import");
                    });
                });

                config.AddBranch("management", management =>
                {
                    management.SetDescription("Commands related to Management.");
                    management.AddBranch("tenants", tenants =>
                    {
                        tenants.SetDescription("Commands related to Tenants Management.");
                        tenants.AddCommand <Commands.Management.Tenants.AddCommand>("add");
                    });
                });

                config.AddBranch("model", model =>
                {
                    model.SetDescription("Commands related to Tenant Model.");
                    model.AddCommand <Commands.Model.ExportCommand>("export");
                    model.AddCommand <Commands.Model.Import.ImportCommand>("import");
                    model.AddCommand <Commands.Model.Apply.ApplyCommand>("apply");
                });

                config.AddBranch("application", application =>
                {
                    application.SetDescription("Commands related to Tenant.");
                    application.AddCommand <Commands.Application.ImportCommand>("import");
                });
            });


            var subscriptions = GetConfiguredSubscriptions(serviceProvider);

            if (subscriptions?.Count == 0)
            {
                ShowWelcomeScreen();
            }

            return(app.Run(args));
        }