public override async Task <int> ExecuteAsync(
            DownloadCommandArguments arguments,
            CancellationToken cancellationToken)
        {
            using IDisposable command = Output.WriteCommand();

            AccessToken?accessToken =
                await arguments.AuthArguments
                .RequestTokenAsync(Output, cancellationToken)
                .ConfigureAwait(false);

            var context = new DownloadCommandContext(
                new Uri(arguments.Uri.Value !),
                FileSystem.ResolvePath(arguments.FileName.Value()?.Trim(), "schema.graphql"),
                accessToken?.Token,
                accessToken?.Scheme,
                CustomHeaderHelper.ParseHeadersArgument(arguments.CustomHeaders.Values));

            FileSystem.EnsureDirectoryExists(
                FileSystem.GetDirectoryName(context.FileName));

            return(await DownloadSchemaAsync(
                       context, cancellationToken)
                   .ConfigureAwait(false)
                ? 0 : 1);
        }
Exemplo n.º 2
0
        public override async Task <int> ExecuteAsync(
            InitCommandArguments arguments,
            CancellationToken cancellationToken)
        {
            using IDisposable command = Output.WriteCommand();

            AccessToken?accessToken =
                await arguments.AuthArguments
                .RequestTokenAsync(Output, cancellationToken)
                .ConfigureAwait(false);

            var context = new InitCommandContext(
                arguments.Name.Value()?.Trim() ?? Path.GetFileName(Environment.CurrentDirectory),
                FileSystem.ResolvePath(arguments.Path.Value()?.Trim()),
                new Uri(arguments.Uri.Value !),
                accessToken?.Token,
                accessToken?.Scheme,
                CustomHeaderHelper.ParseHeadersArgument(arguments.CustomHeaders.Values));

            if (await ExecuteInternalAsync(context, cancellationToken).ConfigureAwait(false))
            {
                return(0);
            }

            return(1);
        }
Exemplo n.º 3
0
        public override async Task <int> ExecuteAsync(
            UpdateCommandArguments arguments,
            CancellationToken cancellationToken)
        {
            using IDisposable command = Output.WriteCommand();

            AccessToken?accessToken =
                await arguments.AuthArguments
                .RequestTokenAsync(Output, cancellationToken)
                .ConfigureAwait(false);

            var context = new UpdateCommandContext(
                arguments.Uri.HasValue() ? new Uri(arguments.Uri.Value() !.Trim()) : null,
                FileSystem.ResolvePath(arguments.Path.Value()?.Trim()),
                accessToken?.Token,
                accessToken?.Scheme,
                CustomHeaderHelper.ParseHeadersArgument(arguments.CustomHeaders.Values));

            return(context.Path is null
                ? await FindAndUpdateSchemasAsync(context, cancellationToken)
                   .ConfigureAwait(false)
                : await UpdateSingleSchemaAsync(context, context.Path, cancellationToken)
                   .ConfigureAwait(false));
        }