Esempio n. 1
0
        private static void RegisterInstallSubcommand(CommandLineApplication commandsCmd, ReportsFactory reportsFactory, IApplicationEnvironment appEnvironment)
        {
            commandsCmd.Command("install", c =>
            {
                c.Description = "Installs application commands";

                var argPackage = c.Argument("[package]", "The name of the application package");
                var argVersion = c.Argument("[version]", "The version of the application package");

                var optOverwrite = c.Option("-o|--overwrite", "Overwrites package and conflicting commands", CommandOptionType.NoValue);

                var feedCommandLineOptions = FeedCommandLineOptions.Add(c);

                c.HelpOption("-?|-h|--help");

                c.OnExecute(async () =>
                {
                    c.ShowRootCommandFullNameAndVersion();

                    var feedOptions = feedCommandLineOptions.GetOptions();
                    var command = new InstallGlobalCommand(
                            appEnvironment,
                            string.IsNullOrEmpty(feedOptions.TargetPackagesFolder) ?
                                AppCommandsFolderRepository.CreateDefault() :
                                AppCommandsFolderRepository.Create(feedOptions.TargetPackagesFolder));

                    command.FeedOptions = feedOptions;
                    command.Reports = reportsFactory.CreateReports(feedOptions.Quiet);
                    command.OverwriteCommands = optOverwrite.HasValue();

                    if (feedOptions.Proxy != null)
                    {
                        Environment.SetEnvironmentVariable("http_proxy", feedOptions.Proxy);
                    }

                    if (argPackage.Value == null)
                    {
                        c.ShowHelp();
                        return 2;
                    }

                    var success = await command.Execute(argPackage.Value, argVersion.Value);
                    return success ? 0 : 1;
                });
            });
        }
Esempio n. 2
0
        private static void RegisterInstallSubcommand(CommandLineApplication commandsCmd, ReportsFactory reportsFactory, IApplicationEnvironment appEnvironment)
        {
            commandsCmd.Command("install", c =>
            {
                c.Description = "Installs application commands";

                var argPackage = c.Argument("[package]", "The name of the application package");
                var argVersion = c.Argument("[version]", "The version of the application package");

                var optOverwrite = c.Option("-o|--overwrite", "Overwrites package and conflicting commands", CommandOptionType.NoValue);

                var feedCommandLineOptions = FeedCommandLineOptions.Add(c);

                c.HelpOption("-?|-h|--help");

                c.OnExecute(async() =>
                {
                    c.ShowRootCommandFullNameAndVersion();

                    var feedOptions = feedCommandLineOptions.GetOptions();
                    var command     = new InstallGlobalCommand(
                        appEnvironment,
                        string.IsNullOrEmpty(feedOptions.TargetPackagesFolder) ?
                        AppCommandsFolderRepository.CreateDefault() :
                        AppCommandsFolderRepository.Create(feedOptions.TargetPackagesFolder));

                    command.FeedOptions       = feedOptions;
                    command.Reports           = reportsFactory.CreateReports(feedOptions.Quiet);
                    command.OverwriteCommands = optOverwrite.HasValue();

                    if (feedOptions.Proxy != null)
                    {
                        Environment.SetEnvironmentVariable("http_proxy", feedOptions.Proxy);
                    }

                    if (argPackage.Value == null)
                    {
                        c.ShowHelp();
                        return(2);
                    }

                    var success = await command.Execute(argPackage.Value, argVersion.Value);
                    return(success ? 0 : 1);
                });
            });
        }