public static Command Create()
        {
            var command = new Command(
                name: "remove",
                description: CoreStrings.RemoveCommandDescription);

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

            command.AddOption(CommonOptions.ProjectOption());

            command.Handler = CommandHandler.Create <IConsole, FileInfo, string[]>(
                (console, project, references) =>
            {
                try
                {
                    var command = new RemoveCommand(console, project);
                    command.Remove(references);

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

                    return(-1);
                }
            });

            return(command);
        }
示例#2
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);
        }