Exemplo n.º 1
0
        public override Command Create()
        {
            var command = new Command("connect", "Connects to an API endpoint.");

            command.AddOption(new Option <string>(
                                  new[] { "--endpoint", "-e" },
                                  description: $"The API endpoint to connect to (defaults to {ConnectionManager.DefaultApiEndpoint}).",
                                  getDefaultValue: () => ConnectionManager.DefaultApiEndpoint));

            command.AddOption(new Option <string>(
                                  new[] { "--client-id", "-c" },
                                  description: $"Your client ID, as provided by Canopy Simulations.",
                                  getDefaultValue: () => string.Empty));

            command.AddOption(new Option <string>(
                                  new[] { "--client-secret", "-s" },
                                  description: $"Your client secret, as provided by Canopy Simulations.",
                                  getDefaultValue: () => string.Empty));

            command.Handler = CommandHandler.Create((IHost host, Parameters parameters) =>
                                                    host.Services.GetRequiredService <CommandRunner>().ExecuteAsync(
                                                        parameters with
            {
                ClientId     = CommandUtilities.ValueOrPrompt(parameters.ClientId, "Client ID: ", "Client ID is required.", false),
                ClientSecret = CommandUtilities.ValueOrPrompt(parameters.ClientSecret, "Client Secret: ", "Client Secret is required.", true),
            }));

            return(command);
        }
        public override Command Create()
        {
            var command = new Command("create-user", "Creates a new user for the current tenant.");

            command.AddOption(new Option <string>(
                                  new[] { "--username", "-u" },
                                  description: "New username.",
                                  getDefaultValue: () => string.Empty));

            command.AddOption(new Option <string>(
                                  new[] { "--email", "-e" },
                                  description: "User's email address.",
                                  getDefaultValue: () => string.Empty));

            command.AddOption(new Option <string>(
                                  new[] { "--password", "-p" },
                                  description: "User's password.",
                                  getDefaultValue: () => string.Empty));

            command.Handler = CommandHandler.Create((IHost host, Parameters parameters) =>
                                                    host.Services.GetRequiredService <CommandRunner>().ExecuteAsync(
                                                        parameters with
            {
                Username = CommandUtilities.ValueOrPrompt(parameters.Username, "Username: "******"Username is required.", false),
                Email    = CommandUtilities.ValueOrPrompt(parameters.Email, "Email: ", "Email is required.", false),
                Password = CommandUtilities.ValueOrPrompt(parameters.Password, "Password: "******"Password is required.", true),
            }));

            return(command);
        }
        public override Command Create()
        {
            var command = new Command("authenticate", "Authenticates with the API.");

            command.AddOption(new Option <string>(
                                  new[] { "--username", "-u" },
                                  description: "Your username.",
                                  getDefaultValue: () => string.Empty));

            command.AddOption(new Option <string>(
                                  new[] { "--company", "-c" },
                                  description: "Your company.",
                                  getDefaultValue: () => string.Empty));

            command.AddOption(new Option <string>(
                                  new[] { "--password", "-p" },
                                  description: "Your password.",
                                  getDefaultValue: () => string.Empty));

            command.Handler = CommandHandler.Create((IHost host, Parameters parameters) =>
                                                    host.Services.GetRequiredService <CommandRunner>().ExecuteAsync(
                                                        parameters with
            {
                Username = CommandUtilities.ValueOrPrompt(parameters.Username, "Username: "******"Username is required.", false),
                Company  = CommandUtilities.ValueOrPrompt(parameters.Company, "Company: ", "Company is required.", false),
                Password = CommandUtilities.ValueOrPrompt(parameters.Password, "Password: "******"Password is required.", true),
            }));

            return(command);
        }
Exemplo n.º 4
0
        public override Command Create()
        {
            var command = new Command("get-configs", "Lists or downloads configs of the specified type.");

            command.AddOption(new Option <string>(
                                  new[] { "--config-type", "-t" },
                                  description: $"The config type to request (e.g. car).",
                                  getDefaultValue: () => string.Empty));

            command.AddOption(new Option <string>(
                                  new[] { "--user-id", "-uid" },
                                  description: $"Filter by user ID.",
                                  getDefaultValue: () => string.Empty));

            command.AddOption(new Option <string>(
                                  new[] { "--username", "-u" },
                                  description: $"Filter by username.",
                                  getDefaultValue: () => string.Empty));

            command.AddOption(new Option <DirectoryInfo?>(
                                  new[] { "--output-folder", "-o" },
                                  description: $"The output folder in which to save the files (optional).",
                                  getDefaultValue: () => null));

            command.AddOption(new Option <string>(
                                  new[] { "--sim-version", "-v" },
                                  description: $"Get config for specific schema version (optional).",
                                  getDefaultValue: () => string.Empty));

            command.AddOption(new Option <bool>(
                                  new[] { "--unwrap" },
                                  description: $"Unwrap the config (removes metadata such as sim version required for importing).",
                                  getDefaultValue: () => false));

            command.AddOption(new Option <bool>(
                                  new[] { "--format", "-f" },
                                  description: $"Format the config JSON.",
                                  getDefaultValue: () => false));

            command.Handler = CommandHandler.Create(async(IHost host, Parameters parameters) =>
                                                    await host.Services.GetRequiredService <IGetConfigs>().ExecuteAsync(
                                                        parameters with
            {
                ConfigType = CommandUtilities.ValueOrPrompt(parameters.ConfigType, "Config Type: ", "Config type is required.", false),
            }));

            return(command);
        }
Exemplo n.º 5
0
        public override Command Create()
        {
            var command = new Command("hash", "Hashes a given string. Defaults to SHA256.");

            command.AddArgument(new Argument <string>(
                                    "input",
                                    description: "The input string to hash.",
                                    getDefaultValue: () => string.Empty));

            command.Handler = CommandHandler.Create((IHost host, Parameters parameters) =>
                                                    host.Services.GetRequiredService <CommandRunner>().ExecuteAsync(
                                                        parameters with
            {
                Input = CommandUtilities.ValueOrPrompt(parameters.Input, "Input string: ", "Input string is required.", false),
            }));

            return(command);
        }