예제 #1
0
        public static CommandLineApplication Create()
        {
            var init = new CommandLineApplication();

            init.AddName("init");
            init.AddHelp <InitHelpTextGenerator>();

            CommandArgument uriArg = init.Argument(
                "uri",
                "The URL to the GraphQL endpoint.",
                c => c.IsRequired());

            CommandOption pathArg = init.Option(
                "-p|--Path",
                "The directory where the client shall be located.",
                CommandOptionType.SingleValue);

            CommandOption schemaArg = init.Option(
                "-n|--SchemaName",
                "The schema name.",
                CommandOptionType.SingleValue);

            CommandOption tokenArg = init.Option(
                "-t|--token",
                "The token that shall be used to autheticate with the GraphQL server.",
                CommandOptionType.SingleValue);

            CommandOption schemeArg = init.Option(
                "-s|--scheme",
                "The token scheme (defaul: bearer).",
                CommandOptionType.SingleValue);

            CommandOption jsonArg = init.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            init.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new InitCommandArguments(
                    uriArg, pathArg, schemaArg, tokenArg, schemeArg);
                var handler = CommandTools.CreateHandler <InitCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });

            return(init);
        }
예제 #2
0
        public static void Build(CommandLineApplication init)
        {
            init.Description = "Initialize project and download schema";

            CommandArgument uriArg = init.Argument(
                "uri",
                "The URL to the GraphQL endpoint.",
                c => c.IsRequired());

            CommandOption pathArg = init.Option(
                "-p|--Path",
                "The directory where the client shall be located.",
                CommandOptionType.SingleValue);

            CommandOption nameArg = init.Option(
                "-n|--clientName",
                "The GraphQL client name.",
                CommandOptionType.SingleValue);

            CommandOption jsonArg = init.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            CommandOption headersArg = init.Option(
                "-x|--headers",
                "Custom headers used in request to Graph QL server. " +
                "Can be used mulitple times. Example: --headers key1=value1 --headers key2=value2",
                CommandOptionType.MultipleValue);

            AuthArguments authArguments = init.AddAuthArguments();

            init.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new InitCommandArguments(
                    uriArg,
                    pathArg,
                    nameArg,
                    authArguments,
                    headersArg);
                InitCommandHandler handler =
                    CommandTools.CreateHandler <InitCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });
        }
예제 #3
0
        public static CommandLineApplication Create()
        {
            var init = new CommandLineApplication();

            init.AddName("init");
            init.AddHelp <InitHelpTextGenerator>();

            CommandArgument uriArg = init.Argument(
                "uri",
                "The URL to the GraphQL endpoint.",
                c => c.IsRequired());

            CommandOption pathArg = init.Option(
                "-p|--Path",
                "The directory where the client shall be located.",
                CommandOptionType.SingleValue);

            CommandOption nameArg = init.Option(
                "-n|--clientName",
                "The GraphQL client name.",
                CommandOptionType.SingleValue);

            CommandOption jsonArg = init.Option(
                "-j|--json",
                "Console output as JSON.",
                CommandOptionType.NoValue);

            AuthArguments authArguments = init.AddAuthArguments();

            init.OnExecuteAsync(cancellationToken =>
            {
                var arguments = new InitCommandArguments(
                    uriArg,
                    pathArg,
                    nameArg,
                    authArguments);
                InitCommandHandler handler =
                    CommandTools.CreateHandler <InitCommandHandler>(jsonArg);
                return(handler.ExecuteAsync(arguments, cancellationToken));
            });

            return(init);
        }