Exemplo n.º 1
0
        public override async Task <CommandResult> ExecuteAsync(CancellationToken cancellationToken)
        {
            Arguments ??= Enumerable.Empty <string>();

            reporter.WriteInfo($"Executing {nameof(PackageCommand)}");
            reporter.WriteInfo($"Arguments: {String.Join(", ", Arguments)}");
            reporter.WriteInfo($"Option {nameof(Owner)}: {Owner ?? "<null>"}");
            reporter.WriteInfo($"Option {nameof(Tag)}: {Tag ?? "<null>"}");
            reporter.WriteInfo($"Option {nameof(Skip)}: {Skip}");
            reporter.WriteInfo($"Option {nameof(Take)}: {Take}");
            reporter.WriteLine();

            reporter.WriteInfo($"Hosting environment: {environment.EnvironmentName}");
            reporter.WriteInfo($"Application name: {environment.ApplicationName}");
            reporter.WriteInfo($"Content root path: {environment.ContentRootPath}");
            reporter.WriteLine();

            if (Owner is not null)
            {
                string info = await nuGetService.GetByOwnerAsync(Owner, cancellationToken);

                reporter.WriteInfo(info);
            }

            reporter.WriteLine();

            foreach (string argument in Arguments)
            {
                string package = await nuGetService.GetByIdAsync(argument, cancellationToken);

                reporter.WriteInfo($"- {package}");
            }

            reporter.WriteLine();

            if (Tag is not null)
            {
                string data = await nuGetService.GetByTagAsync(Tag, Skip, Take, cancellationToken);

                reporter.WriteInfo(data);
            }

            reporter.WriteInfo($"Executed {nameof(PackageCommand)}");
            return(Success());
        }