Example #1
0
        public static Command Create()
        {
            var command = new Command(
                name: "refresh",
                description: CoreStrings.RefreshCommandDescription);

            command.AddArgument(new Argument <string[]>
            {
                Name        = "references",
                Description = CoreStrings.RefreshCommandArgumentDescription,
                Arity       = ArgumentArity.ZeroOrMore
            });
            command.AddOption(CommonOptions.ProjectOption());
            command.AddOption(new Option(
                                  aliases: new[] { "--dry-run" },
                                  description: CoreStrings.DryRunOptionDescription
                                  ));

            command.Handler = CommandHandler.Create <IConsole, FileInfo, bool, string[]>(
                async(console, project, dryRun, references) =>
            {
                try
                {
                    var command = new RefreshCommand(console, project);
                    await command.RefreshAsync(dryRun, references);

                    return(0);
                }
                catch (CLIToolException e)
                {
                    console.LogError(e);

                    return(-1);
                }
            });

            return(command);
        }
        public static Command Create()
        {
            var command = new Command(
                name: "add-file",
                description: CoreStrings.AddFileCommandDescription);

            command.AddArgument(new Argument <string[]>
            {
                Name        = "files",
                Description = CoreStrings.AddFileCommandArgumentDescription,
                Arity       = ArgumentArity.OneOrMore
            });

            command.AddOption(CommonOptions.ProjectOption());
            command.AddOption(CommonOptions.ServiceOption());
            command.AddOption(CommonOptions.AdditionalImportDirsOption());
            command.AddOption(CommonOptions.AccessOption());

            command.Handler = CommandHandler.Create <IConsole, FileInfo, Services, Access, string, string[]>(
                async(console, project, services, access, additionalImportDirs, files) =>
            {
                try
                {
                    var command = new AddFileCommand(console, project);
                    await command.AddFileAsync(services, access, additionalImportDirs, files);

                    return(0);
                }
                catch (CLIToolException e)
                {
                    console.LogError(e);

                    return(-1);
                }
            });

            return(command);
        }
Example #3
0
        public static Command Create(HttpClient httpClient)
        {
            var command = new Command(
                name: "remove",
                description: CoreStrings.RemoveCommandDescription);

            var projectOption      = CommonOptions.ProjectOption();
            var referencesArgument = new Argument <string[]>
            {
                Name        = "references",
                Description = CoreStrings.RemoveCommandArgumentDescription,
                Arity       = ArgumentArity.OneOrMore
            };

            command.AddOption(projectOption);
            command.AddArgument(referencesArgument);

            command.SetHandler <string, string[], InvocationContext, IConsole>(
                (project, references, context, console) =>
            {
                try
                {
                    var command = new RemoveCommand(console, project, httpClient);
                    command.Remove(references);

                    context.ExitCode = 0;
                }
                catch (CLIToolException e)
                {
                    console.LogError(e);

                    context.ExitCode = -1;
                }
            }, projectOption, referencesArgument);

            return(command);
        }