From 7734338b0e8f1cf40d937ca60b7c705ca03ed115 Mon Sep 17 00:00:00 2001 From: Romain Demeure Date: Wed, 13 Aug 2025 13:31:40 +0200 Subject: [PATCH 1/3] :sparkles: feat: add new shortcut --- oks_cli/cache.py | 12 ++--- oks_cli/cluster.py | 132 +++++++++++++++++++++------------------------ oks_cli/main.py | 10 ++-- oks_cli/profile.py | 30 +++++------ oks_cli/project.py | 69 ++++++++++++------------ oks_cli/quotas.py | 4 +- 6 files changed, 124 insertions(+), 133 deletions(-) diff --git a/oks_cli/cache.py b/oks_cli/cache.py index a5b539f..86e23b9 100644 --- a/oks_cli/cache.py +++ b/oks_cli/cache.py @@ -5,8 +5,8 @@ # DEFINE THE CACHE COMMAND GROUP @click.group(help="Cache related commands.") @click.option('--project-name', '-p', required = False, help="Project Name") -@click.option('--cluster-name', '-c', required = False, help="Cluster Name") -@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--cluster-name', '--name', '-c', required = False, help="Cluster Name") +@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cache(ctx, project_name, cluster_name, profile): """CLI command group for cache-related operations.""" @@ -21,10 +21,10 @@ def delete_cache(force): @cache.command('kubeconfigs', help="List cached kubeconfigs") @click.option('--project-name', '-p', required=False, help="Project Name") -@click.option('--cluster-name', '-c', required=False, help="Cluster Name") -@click.option('--plain', is_flag=True, help="Plain table format") -@click.option('--msword', is_flag=True, help="Microsoft Word table format") -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name") +@click.option('--plain', '-pl', is_flag=True, help="Plain table format") +@click.option('--msword', '-mw', is_flag=True, help="Microsoft Word table format") +@click.option('--profile', "-pr", help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def list_kubeconfigs(ctx, project_name, cluster_name, plain, msword, profile): """Display cached kubeconfigs with expiration dates in table format.""" diff --git a/oks_cli/cluster.py b/oks_cli/cluster.py index b078a31..b3f6c16 100644 --- a/oks_cli/cluster.py +++ b/oks_cli/cluster.py @@ -19,11 +19,9 @@ # DEFINE THE CLUSTER GROUP @click.group(help="Cluster related commands.") -@click.option('--project', 'project_name', required = False, help="Project Name") -@click.option('--project-name', '-p', required = False, help="Project Name") -@click.option('--name', 'cluster_name', required = False, help="Cluster Name") -@click.option('--cluster-name', '-c', required = False, help="Cluster Name") -@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--project-name', '-p', required=False, help="Project Name") +@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name") +@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster(ctx, project_name, cluster_name, profile): """Group of commands related to cluster management.""" @@ -31,8 +29,8 @@ def cluster(ctx, project_name, cluster_name, profile): # LOGIN ON CLUSTER @cluster.command('login', help="Set a default cluster") -@click.option('--cluster-name', '-c', required=False, help="Name of cluster") -@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--cluster-name', '--name', '-c', required=False, help="Name of cluster") +@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_login(ctx, cluster_name, profile): """Set the specified cluster as the default active cluster.""" @@ -59,7 +57,7 @@ def cluster_login(ctx, cluster_name, profile): # LOGOUT ON CLUSTER @cluster.command('logout', help="Unset default cluster") -@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) +@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_logout(ctx, profile): """Clear the current default cluster selection.""" @@ -71,14 +69,13 @@ def cluster_logout(ctx, profile): # LIST CLUSTERS @cluster.command('list', help="List all clusters") @click.option('--project-name', '-p', required=False, help="Project Name") -@click.option('--name', 'cluster_name', required = False, help="Cluster Name") -@click.option('--cluster-name', '-c', required = False, help="Cluster Name") -@click.option('--deleted', is_flag=True, help="List deleted clusters") -@click.option('--plain', is_flag=True, help="Plain table format") -@click.option('--msword', is_flag=True, help="Microsoft Word table format") +@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name") +@click.option('--deleted', '-x', is_flag=True, help="List deleted clusters") # x pour "deleted" / "removed" +@click.option('--plain', '-pl', is_flag=True, help="Plain table format") +@click.option('--msword', '-mw', is_flag=True, help="Microsoft Word table format") @click.option('--watch', '-w', is_flag=True, help="Watch the changes") -@click.option('-o', '--output', type=click.Choice(["json", "yaml", "wide"]), help="Specify output format") -@click.option('--profile', help="Configuration profile to use") +@click.option('--output', '-o', type=click.Choice(["json", "yaml", "wide"]), help="Specify output format") +@click.option('--profile', '-pr', help="Configuration profile to use") @click.pass_context def cluster_list(ctx, project_name, cluster_name, deleted, plain, msword, watch, output, profile): """Display clusters with optional filtering and real-time monitoring.""" @@ -215,11 +212,10 @@ def format_row(cluster): # GET CLUSTER BY NAME @cluster.command('get', help="Get a cluster by name") -@click.option('--project-name', '-p', required = False, help="Project Name") -@click.option('--name', 'cluster_name', required=False, help="Cluster Name") -@click.option('--cluster-name', '-c', required=False, help="Cluster Name") -@click.option('-o', '--output', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--project-name', '-p', required=False, help="Project Name") +@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name") +@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_get_command(ctx, project_name, cluster_name, output, profile): """Retrieve and display detailed information about a specific cluster.""" @@ -313,23 +309,23 @@ def _create_cluster(project_name, cluster_config, output): @cluster.command('create', help="Create a new cluster") @click.option('--project-name', '-p', required=False, help="Project Name") @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name") -@click.option('--description', help="Description of the cluster") -@click.option('--admin', help="Admin Whitelist") -@click.option('--version', shell_complete=shell_completions, help="Kubernetes version") +@click.option('--description', '-d', help="Description of the cluster") +@click.option('--admin', '-a', help="Admin Whitelist") +@click.option('--version', '-v', shell_complete=shell_completions, help="Kubernetes version") @click.option('--cidr-pods', help="CIDR of pods") @click.option('--cidr-service', help='CIDR of services') @click.option('--control-plane', shell_complete=shell_completions, help="Controlplane plan") -@click.option('--zone', multiple=True, shell_complete=shell_completions, help="List of Control Plane availability zones") +@click.option('--zone', '-z', multiple=True, shell_complete=shell_completions, help="List of Control Plane availability zones") @click.option('--enable-admission-plugins', help="List of admission plugins, separated by commas") @click.option('--disable-admission-plugins', help="List of admission plugins, separated by commas") -@click.option('--quirk', multiple=True, help="Quirk") -@click.option('--tags', help="Comma-separated list of tags, example: 'key1=value1,key2=value2'") +@click.option('--quirk', '-q', multiple=True, help="Quirk") +@click.option('--tags', '-t', help="Comma-separated list of tags, example: 'key1=value1,key2=value2'") @click.option('--disable-api-termination', type=click.BOOL, help="Disable delete action by API") -@click.option('--cp-multi-az', is_flag=True, help="enable control plane multi az") +@click.option('--cp-multi-az', '-m', is_flag=True, help="Enable control plane multi AZ") @click.option('--dry-run', is_flag=True, help="Client dry-run, only print the object that would be sent, without sending it") -@click.option('-o', '--output', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('-f', '--filename', type=click.File("r"), help="Path to file to use to create the cluster ") -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") +@click.option('--filename', '-f', type=click.File("r"), help="Path to file to use to create the cluster ") +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_create_command(ctx, project_name, cluster_name, description, admin, version, cidr_pods, cidr_service, control_plane, zone, enable_admission_plugins, disable_admission_plugins, quirk, tags, disable_api_termination, cp_multi_az, dry_run, output, filename, profile): """CLI command to create a new Kubernetes cluster with optional configuration parameters.""" @@ -412,21 +408,20 @@ def cluster_create_command(ctx, project_name, cluster_name, description, admin, # UPDATE CLUSTER @cluster.command('update', help="Update a cluster by name") @click.option('--project-name', '-p', required=False, help="Project name") -@click.option('--name', 'cluster_name', required=False, help="Cluster name") -@click.option('--cluster-name', '-c', required=False, help="Cluster name") -@click.option('--description', help="Description of the cluster") -@click.option('--admin', help="Admin Whitelist") -@click.option('--version', shell_complete=shell_completions, help="Kubernetes version") -@click.option('--tags', help="Comma-separated list of tags, example: 'key1=value1,key2=value2'") +@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster name") +@click.option('--description', '-d', help="Description of the cluster") +@click.option('--admin', '-a', help="Admin Whitelist") +@click.option('--version', '-v', shell_complete=shell_completions, help="Kubernetes version") +@click.option('--tags', '-t', help="Comma-separated list of tags, example: 'key1=value1,key2=value2'") @click.option('--enable-admission-plugins', help="List of admission plugins, separated by commas") @click.option('--disable-admission-plugins', help="List of admission plugins, separated by commas") -@click.option('--quirk', multiple=True, help="Quirk") +@click.option('--quirk', '-q', multiple=True, help="Quirk") @click.option('--disable-api-termination', type=click.BOOL, help="Disable delete action by API") @click.option('--control-plane', shell_complete=shell_completions, help="Controlplane plan") @click.option('--dry-run', is_flag=True, help="Client dry-run, only print the object that would be sent, without sending it") -@click.option('-o', '--output', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('-f', '--filename', type=click.File("r"), help="Path to file to use to update the cluster ") -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") +@click.option('--filename', '-f', type=click.File("r"), help="Path to file to use to update the cluster ") +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_update_command(ctx, project_name, cluster_name, description, admin, version, tags, enable_admission_plugins, disable_admission_plugins, quirk, disable_api_termination, control_plane, dry_run, output, filename, profile): """CLI command to update an existing Kubernetes cluster with new configuration options.""" @@ -500,11 +495,10 @@ def cluster_update_command(ctx, project_name, cluster_name, description, admin, # UPGRADE CLUSTER @cluster.command('upgrade', help="Upgrade a cluster by name") @click.option('--project-name', '-p', required=False, help="Project name") -@click.option('--name', 'cluster_name', required=False, help="Cluster name") -@click.option('--cluster-name', '-c', required=False, help="Cluster name") -@click.option('-o', '--output', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") +@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster name") +@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--force', is_flag=True, help="Force upgrade") -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_update_command(ctx, project_name, cluster_name, output, force, profile): """CLI command to upgrade an existing Kubernetes cluster to the latest supported version.""" @@ -522,12 +516,11 @@ def cluster_update_command(ctx, project_name, cluster_name, output, force, profi # DELETE CLUSTER BY NAME @cluster.command('delete', help="Delete a cluster by name") @click.option('--project-name', '-p', required=False, help="Project name") -@click.option('--name', 'cluster_name', required=False, help="Cluster name") -@click.option('--cluster-name', '-c', required=False, help="Cluster name") -@click.option('-o', '--output', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") +@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster name") +@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--dry-run', is_flag=True, help="Run without any action") @click.option('--force', is_flag=True, help="Force deletion without confirmation") -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_delete_command(ctx, project_name, cluster_name, output, dry_run, force, profile): """CLI command to delete an existing Kubernetes cluster by name.""" @@ -554,15 +547,14 @@ def cluster_delete_command(ctx, project_name, cluster_name, output, dry_run, for # GET KUBECONFIG @cluster.command('kubeconfig', help="Fetch the kubeconfig for a cluster") @click.option('--project-name', '-p', required=False, help="Project Name") -@click.option('--name', 'cluster_name', required=False, help="Cluster name") -@click.option('--cluster-name', '-c', required=False, help="Cluster Name") -@click.option('--print-path', is_flag=True, help="Print path to saved kubeconfig") +@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name") +@click.option('--print-path', '-pp', is_flag=True, help="Print path to saved kubeconfig") @click.option('--refresh', '--force', is_flag=True, help="Force refresh saved kubeconfig") @click.option('--nacl', is_flag=True, help="Use public key encryption on wire (require api support)") -@click.option('--user', type=click.STRING, help="User") -@click.option('--group', type=click.STRING, help="Group") -@click.option('--ttl', type=click.STRING, help="TTL in human readable format (5h, 1d, 1w)") -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--user', '-u', type=click.STRING, help="User") +@click.option('--group', '-g', type=click.STRING, help="Group") +@click.option('--ttl', '-t', type=click.STRING, help="TTL in human readable format (5h, 1d, 1w)") +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_kubeconfig_command(ctx, project_name, cluster_name, print_path, refresh, nacl, user, group, ttl, profile): """CLI command to fetch and optionally print the kubeconfig for a specified cluster.""" @@ -664,11 +656,11 @@ def _run_kubectl(project_id, cluster_id, user, group, args, input=None): @cluster.command('kubectl', help='Fetch the kubeconfig for a cluster and run kubectl against it', context_settings={"ignore_unknown_options": True}) @click.option('--project-name', '-p', required=False, help="Project Name") -@click.option('--cluster-name', '-c', required=False, help="Cluster Name") -@click.option('--user', type=click.STRING, help="User") -@click.option('--group', type=click.STRING, help="Group") +@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name") +@click.option('--user', '-u', type=click.STRING, help="User") +@click.option('--group', '-g', type=click.STRING, help="Group") +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.argument("args", nargs=-1, type=click.UNPROCESSED) -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_kubectl_command(ctx, project_name, cluster_name, user, group, args, profile): """CLI command to run kubectl against a specified cluster using its kubeconfig.""" @@ -681,12 +673,12 @@ def cluster_kubectl_command(ctx, project_name, cluster_name, user, group, args, _run_kubectl(project_id, cluster_id, user, group, args) -@click.group(help="nodepool related commands.") +@click.group(help="Nodepool related commands.") @click.option('--project-name', '-p', required=False, help="Project Name") -@click.option('--cluster-name', '-c', required=False, help="Cluster Name") -@click.option('--user', type=click.STRING, help="User") -@click.option('--group', type=click.STRING, help="Group") -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name") +@click.option('--user', '-u', type=click.STRING, help="User") +@click.option('--group', '-g', type=click.STRING, help="Group") +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def nodepool(ctx, project_name, cluster_name, user, group, profile): """CLI group for nodepool-related commands, managing project, cluster, user, and profile context.""" @@ -711,14 +703,14 @@ def nodepool_list(ctx): 'get', 'nodepool', '-o', 'wide']) -@nodepool.command('create') +@nodepool.command('create', help="Create a new nodepool") @click.option('--nodepool-name', '-n', default="nodepool01", help="Nodepool Name") -@click.option('--count', default=2, help="Count of nodes") -@click.option('--type', 'vmtype', default="tinav6.c2r4p3", help="Type of VMs") -@click.option('--zone', multiple=True, required=True, help="Provide zone") -@click.option('-o', '--output', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") +@click.option('--count', '-c', default=2, help="Count of nodes") +@click.option('--type', 'vmtype', '-t', default="tinav6.c2r4p3", help="Type of VMs") +@click.option('--zone', '-z', multiple=True, required=True, help="Provide zone(s)") +@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--dry-run', is_flag=True, help="Run without any action") -@click.option('-f', '--filename', type=click.File("r"), help="Path to file to use to create the Nodepool ") +@click.option('--filename', '-f', type=click.File("r"), help="Path to file to use to create the Nodepool") @click.pass_context def setup_worker_pool(ctx, nodepool_name, count, vmtype, zone, output, dry_run, filename): """Create a new nodepool in the cluster, optionally from a file or parameters.""" diff --git a/oks_cli/main.py b/oks_cli/main.py index ecf7d5b..920c78f 100755 --- a/oks_cli/main.py +++ b/oks_cli/main.py @@ -9,14 +9,14 @@ from .cache import cache from .quotas import quotas -from .utils import ctx_update, login_profile, install_completions, profile_completer +from .utils import ctx_update, install_completions, profile_completer # Main CLI entry point @click.group(invoke_without_command=True) -@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) -@click.option('--project-name', '-p', required = False, help="Project Name") -@click.option('--cluster-name', '-c', required = False, help="Cluster Name") -@click.option('-v', '--verbose', count=True) +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--project-name', '-p', required=False, help="Project Name") +@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name") +@click.option('--verbose', '-v', count=True, help="Increase verbosity") @click.pass_context def cli(ctx, project_name, cluster_name, profile, verbose): """ diff --git a/oks_cli/profile.py b/oks_cli/profile.py index 1b4ac8d..b9757b7 100644 --- a/oks_cli/profile.py +++ b/oks_cli/profile.py @@ -11,14 +11,14 @@ def profile(): @profile.command('add', help="Add AK/SK or username/password new profile") -@click.option('--profile-name', required=False, help="Name of profile, optional", type=click.STRING) -@click.option('--access-key', required=False, help="AK of profile", type=click.STRING) -@click.option('--secret-key', required=False, help="SK of profile", type=click.STRING) -@click.option('--username', required=False, help="Username", type=click.STRING) -@click.option('--password', required=False, help="Password", type=click.STRING) -@click.option('--region', required=True, help="Region name", type=click.Choice(['eu-west-2', 'cloudgouv-eu-west-1'])) -@click.option('--endpoint', required=False, help="API endpoint", type=click.STRING) -@click.option('--jwt', required=False, help="Enable jwt, by default is false", type=click.BOOL) +@click.option('--profile-name', '--profile', '-pr', required=False, help="Name of profile, optional", type=click.STRING) +@click.option('--access-key', '-ak', required=False, help="AK of profile", type=click.STRING) +@click.option('--secret-key', '-sk', required=False, help="SK of profile", type=click.STRING) +@click.option('--username', '-u', required=False, help="Username", type=click.STRING) +@click.option('--password', '-p', required=False, help="Password", type=click.STRING) +@click.option('--region', '-r', required=True, help="Region name", type=click.Choice(['eu-west-2', 'cloudgouv-eu-west-1'])) +@click.option('--endpoint', '-e', required=False, help="API endpoint", type=click.STRING) +@click.option('--jwt', help="Enable JWT, by default is false") def add_profile(profile_name, access_key, secret_key, username, password, region, endpoint, jwt): """Add a new profile with AK/SK or username/password authentication.""" if not profile_name: @@ -62,10 +62,10 @@ def add_profile(profile_name, access_key, secret_key, username, password, region click.echo(f"Profile {profile_name_styled} has been successfully added") @profile.command('update', help="Update an existing profile") -@click.option('--profile-name', required=True, help="Name of profile", type=click.STRING) -@click.option('--region', required=False, help="Region name", type=click.Choice(['eu-west-2', 'cloudgouv-eu-west-1'])) -@click.option('--endpoint', required=False, help="API endpoint", type=click.STRING) -@click.option('--jwt', required=False, help="Enable jwt, by default is false", type=click.BOOL) +@click.option('--profile-name', '--profile', '-pr', required=True, help="Name of profile", type=click.STRING) +@click.option('--region', '-r', required=False, help="Region name", type=click.Choice(['eu-west-2', 'cloudgouv-eu-west-1'])) +@click.option('--endpoint', '-e', required=False, help="API endpoint", type=click.STRING) +@click.option('--jwt', help="Enable JWT, by default is false") def update_profile(profile_name, region, endpoint, jwt): """Update configuration settings for an existing profile.""" profiles = profile_list() @@ -89,8 +89,8 @@ def update_profile(profile_name, region, endpoint, jwt): click.echo(f"Profile {profile_name} has been successfully updated") @profile.command('delete', help="Delete a profile by name") -@click.option('--profile-name', required=True, help="Name of profile", type=click.STRING) -@click.option('--force', is_flag=True, help="Force deletion without confirmation") +@click.option('--profile-name', '--profile', '-pr', required=True, help="Name of profile", type=click.STRING) +@click.option('--force', '-f', is_flag=True, help="Force deletion without confirmation") def delete_profile(profile_name, force): """Delete a profile with confirmation.""" profiles = profile_list() @@ -104,7 +104,7 @@ def delete_profile(profile_name, force): click.echo(f"Profile {profile_name_bold} has been successfully deleted") @profile.command('list', help="List existing profiles") -@click.option('-o', '--output', type=click.Choice(["json", "yaml", "table", "wide"]), help="Specify output format, by default is wide") +@click.option('--output', '-o', type=click.Choice(["json", "yaml", "table", "wide"]), help="Specify output format, by default is wide") def list_profiles(output): """Display all configured profiles with their settings.""" profiles = profile_list() diff --git a/oks_cli/project.py b/oks_cli/project.py index c50de62..4552098 100644 --- a/oks_cli/project.py +++ b/oks_cli/project.py @@ -10,9 +10,8 @@ # DEIFNE THE PROJECT COMMAND GROUP @click.group(help="Project related commands.") -@click.option('--project', 'project_name', required = False, help="Project Name") -@click.option('--project-name', '-p', required = False, help="Project Name") -@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--project-name', '-p', required=False, help="Project Name") +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project(ctx, project_name, profile): """Group of commands related to project management.""" @@ -21,7 +20,7 @@ def project(ctx, project_name, profile): # LOGIN ON PROJECT @project.command('login', help="Set a default project by name") @click.option('--project-name', '-p', required=False, help="Name of project", type=click.STRING) -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_login(ctx, project_name, profile): """Set a default project by its name and log in.""" @@ -46,7 +45,7 @@ def project_login(ctx, project_name, profile): # LOGOUT ON PROJECT @project.command('logout', help="Unset default project") -@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) +@click.option("--profile", '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_logout(ctx, profile): """Unset the current default project and log out.""" @@ -59,13 +58,13 @@ def project_logout(ctx, profile): # LIST PROJECTS @project.command('list', help="List all projects") @click.option('--project-name', '-p', help="Name of project", type=click.STRING) -@click.option('--deleted', is_flag=True, help="List deleted projects") -@click.option('--plain', is_flag=True, help="Plain table format") -@click.option('--msword', is_flag=True, help="Microsoft Word table format") -@click.option('--uuid', is_flag=True, help="show uuid") +@click.option('--deleted', '-x', is_flag=True, help="List deleted projects") +@click.option('--plain', '-pl', is_flag=True, help="Plain table format") +@click.option('--msword', '-mw', is_flag=True, help="Microsoft Word table format") +@click.option('--uuid', is_flag=True, help="Show UUID") @click.option('--watch', '-w', is_flag=True, help="Watch the changes") -@click.option('-o', '--output', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('--profile', help="Configuration profile to use") +@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") +@click.option('--profile', '-pr', help="Configuration profile to use") @click.pass_context def project_list(ctx, project_name, deleted, plain, msword, uuid, watch, output, profile): """List projects with filtering, formatting, and live watch capabilities.""" @@ -193,16 +192,16 @@ def format_row(project): # CREATE PROJECT BY NAME @project.command('create', help="Create a new project") -@click.option('--project-name', '-p', help="Name of the project") -@click.option('--description', help="Description of the project") +@click.option('--project-name', '-p', help="Name of the project", type=click.STRING) +@click.option('--description', '-d', help="Description of the project") @click.option('--cidr', help='CIDR for the project') -@click.option('--quirk', multiple=True, help="Quirk") -@click.option('--tags', help="Comma-separated list of tags, example: 'key1=value1,key2=value2'") +@click.option('--quirk', '-q', multiple=True, help="Quirk") +@click.option('--tags', '-t', help="Comma-separated list of tags, example: 'key1=value1,key2=value2'") @click.option('--disable-api-termination', type=click.BOOL, help="Disable delete action by API") @click.option('--dry-run', is_flag=True, help="Client dry-run, only print the object that would be sent, without sending it") -@click.option('-o', '--output', type=click.Choice(["json", "yaml", "silent"]), help="Specify output format, by default is json") -@click.option('-f', '--filename', type=click.File("r"), help="Path to file to use to create the project ") -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--output', '-o', type=click.Choice(["json", "yaml", "silent"]), help="Specify output format, by default is json") +@click.option('--filename', '-f', type=click.File("r"), help="Path to file to use to create the project") +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_create(ctx, project_name, description, cidr, quirk, tags, disable_api_termination, dry_run, output, filename, profile): """Create a new project from options or file, with support for dry-run and output formatting.""" @@ -255,8 +254,8 @@ def project_create(ctx, project_name, description, cidr, quirk, tags, disable_ap # GET PROJECT BY NAME @project.command('get', help="Get default project or the project by name") @click.option('--project-name', '-p', help="Name of the project") -@click.option('-o', '--output', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_get(ctx, project_name, output, profile): """Retrieve and display project details by name or default project.""" @@ -270,11 +269,11 @@ def project_get(ctx, project_name, output, profile): # DELETE PROJECT BY NAME @project.command('delete', help="Delete a project by name") -@click.option('--project-name', '-p', required=False, help="Project Name") -@click.option('-o', '--output', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") +@click.option('--project-name', '-p', required=False, help="Project Name", type=click.STRING) +@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--dry-run', is_flag=True, help="Run without any action") @click.option('--force', is_flag=True, help="Force deletion without confirmation") -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_delete_command(ctx, project_name, output, dry_run, force, profile): """Delete a project by name, with optional dry-run and confirmation.""" @@ -302,14 +301,14 @@ def project_delete_command(ctx, project_name, output, dry_run, force, profile): # UPDATE PROJECT BY NAME @project.command('update', help="Update a project by name") -@click.option('--project-name', '-p', required=False, help="Project Name") -@click.option('--description', help="Description of the project") -@click.option('--quirk', multiple=True, help="Quirk") -@click.option('--tags', help="Comma-separated list of tags, example: 'key1=value1,key2=value2'") +@click.option('--project-name', '-p', required=False, help="Project Name", type=click.STRING) +@click.option('--description', '-d', help="Description of the project") +@click.option('--quirk', '-q', multiple=True, help="Quirk") +@click.option('--tags', '-t', help="Comma-separated list of tags, example: 'key1=value1,key2=value2'") @click.option('--disable-api-termination', type=click.BOOL, help="Disable delete action by API") -@click.option('-o', '--output', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") +@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--dry-run', is_flag=True, help="Run without any action") -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_update_command(ctx, project_name, description, quirk, tags, disable_api_termination, output, dry_run, profile): """Update project details by name, supporting dry-run and output formatting.""" @@ -351,8 +350,8 @@ def project_update_command(ctx, project_name, description, quirk, tags, disable_ # GET PROJECT QUOTAS BY PROJECT NAME @project.command('quotas', help="Get project quotas") @click.option('--project-name', '-p', help="Name of the project") -@click.option('-o', '--output', type=click.Choice(["json", "yaml", "table"]), help="Specify output format, by default is json") -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--output', '-o', type=click.Choice(["json", "yaml", "table"]), help="Specify output format, by default is json") +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_get_quotas(ctx, project_name, output, profile): """Retrieve resource quotas for the specified project.""" @@ -379,8 +378,8 @@ def project_get_quotas(ctx, project_name, output, profile): # GET PROJECT SNAPSHOTS BY PROJECT NAME @project.command('snapshots', help="Get project snapshots") @click.option('--project-name', '-p', help="Name of the project") -@click.option('-o', '--output', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") +@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_get(ctx, project_name, output, profile): """Retrieve snapshots associated with the specified project.""" @@ -395,8 +394,8 @@ def project_get(ctx, project_name, output, profile): # GET PUBLIC IPS BY PROJECT NAME @project.command('publicips', help="Get project public ips") @click.option('--project-name', '-p', help="Name of the project") -@click.option('-o', '--output', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('--profile', help="Configuration profile to use") +@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") +@click.option('--profile', '-pr',help="Configuration profile to use") @click.pass_context def project_get_public_ips(ctx, project_name, output, profile): """Retrieve the list of public IPs associated with the specified project.""" diff --git a/oks_cli/quotas.py b/oks_cli/quotas.py index d857b8a..3ec574d 100644 --- a/oks_cli/quotas.py +++ b/oks_cli/quotas.py @@ -3,8 +3,8 @@ from .utils import do_request, print_output, print_table, ctx_update, login_profile, profile_completer @click.command(help="Get Quotas") -@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) -@click.option('-o', '--output', type=click.Choice(["json", "yaml", "table"]), help="Specify output format, by default is json") +@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--output','-o', type=click.Choice(["json", "yaml", "table"]), help="Specify output format, by default is json") @click.pass_context def quotas(ctx, profile, output): """Retrieve global quotas across all projects for the given profile.""" From 0dd703ced40db133c66830823c5738f890340baf Mon Sep 17 00:00:00 2001 From: Romain Demeure Date: Tue, 26 Aug 2025 11:06:59 +0200 Subject: [PATCH 2/3] :sparkles: feat: remove unnecessary shortcuts and remove shortcuts with two letters --- oks_cli/cache.py | 8 ++++---- oks_cli/cluster.py | 44 ++++++++++++++++++++++---------------------- oks_cli/main.py | 2 +- oks_cli/profile.py | 22 +++++++++++----------- oks_cli/project.py | 26 +++++++++++++------------- oks_cli/quotas.py | 2 +- 6 files changed, 52 insertions(+), 52 deletions(-) diff --git a/oks_cli/cache.py b/oks_cli/cache.py index 1b60009..5301c4a 100644 --- a/oks_cli/cache.py +++ b/oks_cli/cache.py @@ -6,7 +6,7 @@ @click.group(help="Cache related commands.") @click.option('--project-name', '-p', required = False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required = False, help="Cluster Name", shell_complete=cluster_completer) -@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer) +@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cache(ctx, project_name, cluster_name, profile): """CLI command group for cache-related operations.""" @@ -22,9 +22,9 @@ def delete_cache(force): @cache.command('kubeconfigs', help="List cached kubeconfigs") @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) -@click.option('--plain', '-pl', is_flag=True, help="Plain table format") -@click.option('--msword', '-mw', is_flag=True, help="Microsoft Word table format") -@click.option('--profile', "-pr", help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--plain', is_flag=True, help="Plain table format") +@click.option('--msword', is_flag=True, help="Microsoft Word table format") +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def list_kubeconfigs(ctx, project_name, cluster_name, plain, msword, profile): """Display cached kubeconfigs with expiration dates in table format.""" diff --git a/oks_cli/cluster.py b/oks_cli/cluster.py index 14d8899..d0bcf6a 100644 --- a/oks_cli/cluster.py +++ b/oks_cli/cluster.py @@ -21,7 +21,7 @@ @click.group(help="Cluster related commands.") @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) -@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer) +@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster(ctx, project_name, cluster_name, profile): """Group of commands related to cluster management.""" @@ -30,7 +30,7 @@ def cluster(ctx, project_name, cluster_name, profile): # LOGIN ON CLUSTER @cluster.command('login', help="Set a default cluster") @click.option('--cluster-name', '--name', '-c', required=False, help="Name of cluster", shell_complete=cluster_completer) -@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer) +@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_login(ctx, cluster_name, profile): """Set the specified cluster as the default active cluster.""" @@ -57,7 +57,7 @@ def cluster_login(ctx, cluster_name, profile): # LOGOUT ON CLUSTER @cluster.command('logout', help="Unset default cluster") -@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer) +@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_logout(ctx, profile): """Clear the current default cluster selection.""" @@ -71,11 +71,11 @@ def cluster_logout(ctx, profile): @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) @click.option('--deleted', '-x', is_flag=True, help="List deleted clusters") # x pour "deleted" / "removed" -@click.option('--plain', '-pl', is_flag=True, help="Plain table format") -@click.option('--msword', '-mw', is_flag=True, help="Microsoft Word table format") +@click.option('--plain', is_flag=True, help="Plain table format") +@click.option('--msword', is_flag=True, help="Microsoft Word table format") @click.option('--watch', '-w', is_flag=True, help="Watch the changes") @click.option('--output', '-o', type=click.Choice(["json", "yaml", "wide"]), help="Specify output format") -@click.option('--profile', '-pr', help="Configuration profile to use") +@click.option('--profile', help="Configuration profile to use") @click.pass_context def cluster_list(ctx, project_name, cluster_name, deleted, plain, msword, watch, output, profile): """Display clusters with optional filtering and real-time monitoring.""" @@ -215,7 +215,7 @@ def format_row(cluster): @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_get_command(ctx, project_name, cluster_name, output, profile): """Retrieve and display detailed information about a specific cluster.""" @@ -325,7 +325,7 @@ def _create_cluster(project_name, cluster_config, output): @click.option('--dry-run', is_flag=True, help="Client dry-run, only print the object that would be sent, without sending it") @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--filename', '-f', type=click.File("r"), help="Path to file to use to create the cluster ") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_create_command(ctx, project_name, cluster_name, description, admin, version, cidr_pods, cidr_service, control_plane, zone, enable_admission_plugins, disable_admission_plugins, quirk, tags, disable_api_termination, cp_multi_az, dry_run, output, filename, profile): """CLI command to create a new Kubernetes cluster with optional configuration parameters.""" @@ -421,7 +421,7 @@ def cluster_create_command(ctx, project_name, cluster_name, description, admin, @click.option('--dry-run', is_flag=True, help="Client dry-run, only print the object that would be sent, without sending it") @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--filename', '-f', type=click.File("r"), help="Path to file to use to update the cluster ") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_update_command(ctx, project_name, cluster_name, description, admin, version, tags, enable_admission_plugins, disable_admission_plugins, quirk, disable_api_termination, control_plane, dry_run, output, filename, profile): """CLI command to update an existing Kubernetes cluster with new configuration options.""" @@ -498,7 +498,7 @@ def cluster_update_command(ctx, project_name, cluster_name, description, admin, @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster name", shell_complete=cluster_completer) @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--force', is_flag=True, help="Force upgrade") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_update_command(ctx, project_name, cluster_name, output, force, profile): """CLI command to upgrade an existing Kubernetes cluster to the latest supported version.""" @@ -520,7 +520,7 @@ def cluster_update_command(ctx, project_name, cluster_name, output, force, profi @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--dry-run', is_flag=True, help="Run without any action") @click.option('--force', is_flag=True, help="Force deletion without confirmation") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_delete_command(ctx, project_name, cluster_name, output, dry_run, force, profile): """CLI command to delete an existing Kubernetes cluster by name.""" @@ -548,13 +548,13 @@ def cluster_delete_command(ctx, project_name, cluster_name, output, dry_run, for @cluster.command('kubeconfig', help="Fetch the kubeconfig for a cluster") @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) -@click.option('--print-path', '-pp', is_flag=True, help="Print path to saved kubeconfig") +@click.option('--print-path', is_flag=True, help="Print path to saved kubeconfig") @click.option('--refresh', '--force', is_flag=True, help="Force refresh saved kubeconfig") @click.option('--nacl', is_flag=True, help="Use public key encryption on wire (require api support)") -@click.option('--user', '-u', type=click.STRING, help="User") -@click.option('--group', '-g', type=click.STRING, help="Group") -@click.option('--ttl', '-t', type=click.STRING, help="TTL in human readable format (5h, 1d, 1w)") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--user', type=click.STRING, help="User") +@click.option('--group', type=click.STRING, help="Group") +@click.option('--ttl', type=click.STRING, help="TTL in human readable format (5h, 1d, 1w)") +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_kubeconfig_command(ctx, project_name, cluster_name, print_path, refresh, nacl, user, group, ttl, profile): """CLI command to fetch and optionally print the kubeconfig for a specified cluster.""" @@ -657,9 +657,9 @@ def _run_kubectl(project_id, cluster_id, user, group, args, input=None): @cluster.command('kubectl', help='Fetch the kubeconfig for a cluster and run kubectl against it', context_settings={"ignore_unknown_options": True}) @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) -@click.option('--user', '-u', type=click.STRING, help="User") -@click.option('--group', '-g', type=click.STRING, help="Group") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--user', type=click.STRING, help="User") +@click.option('--group', type=click.STRING, help="Group") +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.argument("args", nargs=-1, type=click.UNPROCESSED) @click.pass_context def cluster_kubectl_command(ctx, project_name, cluster_name, user, group, args, profile): @@ -676,9 +676,9 @@ def cluster_kubectl_command(ctx, project_name, cluster_name, user, group, args, @click.group(help="Nodepool related commands.") @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) -@click.option('--user', '-u', type=click.STRING, help="User") -@click.option('--group', '-g', type=click.STRING, help="Group") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--user', type=click.STRING, help="User") +@click.option('--group', type=click.STRING, help="Group") +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def nodepool(ctx, project_name, cluster_name, user, group, profile): """CLI group for nodepool-related commands, managing project, cluster, user, and profile context.""" diff --git a/oks_cli/main.py b/oks_cli/main.py index ccbff28..8ee69b4 100755 --- a/oks_cli/main.py +++ b/oks_cli/main.py @@ -13,7 +13,7 @@ # Main CLI entry point @click.group(invoke_without_command=True) -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) @click.option('--verbose', '-v', count=True, help="Increase verbosity") diff --git a/oks_cli/profile.py b/oks_cli/profile.py index ddf29d5..ffbe9bc 100644 --- a/oks_cli/profile.py +++ b/oks_cli/profile.py @@ -11,13 +11,13 @@ def profile(): @profile.command('add', help="Add AK/SK or username/password new profile") -@click.option('--profile-name', '--profile', '-pr', required=False, help="Name of profile, optional", type=click.STRING) -@click.option('--access-key', '-ak', required=False, help="AK of profile", type=click.STRING) -@click.option('--secret-key', '-sk', required=False, help="SK of profile", type=click.STRING) -@click.option('--username', '-u', required=False, help="Username", type=click.STRING) -@click.option('--password', '-p', required=False, help="Password", type=click.STRING) -@click.option('--region', '-r', required=True, help="Region name", type=click.Choice(['eu-west-2', 'cloudgouv-eu-west-1'])) -@click.option('--endpoint', '-e', required=False, help="API endpoint", type=click.STRING) +@click.option('--profile-name', '--profile', required=False, help="Name of profile, optional", type=click.STRING) +@click.option('--access-key', required=False, help="AK of profile", type=click.STRING) +@click.option('--secret-key', required=False, help="SK of profile", type=click.STRING) +@click.option('--username', required=False, help="Username", type=click.STRING) +@click.option('--password', required=False, help="Password", type=click.STRING) +@click.option('--region', required=True, help="Region name", type=click.Choice(['eu-west-2', 'cloudgouv-eu-west-1'])) +@click.option('--endpoint', required=False, help="API endpoint", type=click.STRING) @click.option('--jwt', help="Enable JWT, by default is false") def add_profile(profile_name, access_key, secret_key, username, password, region, endpoint, jwt): """Add a new profile with AK/SK or username/password authentication.""" @@ -62,10 +62,10 @@ def add_profile(profile_name, access_key, secret_key, username, password, region click.echo(f"Profile {profile_name_styled} has been successfully added") @profile.command('update', help="Update an existing profile") -@click.option('--profile-name', '-pr', required=True, help="Name of profile", type=click.STRING) +@click.option('--profile-name', required=True, help="Name of profile", type=click.STRING) @click.option('--new-name', required=False, help="Update profile name with new one, USE IT WITH CAUTION", type=click.STRING) -@click.option('--region', '-r', required=False, help="Region name", type=click.Choice(['eu-west-2', 'cloudgouv-eu-west-1'])) -@click.option('--endpoint', '-e', required=False, help="API endpoint", type=click.STRING) +@click.option('--region', required=False, help="Region name", type=click.Choice(['eu-west-2', 'cloudgouv-eu-west-1'])) +@click.option('--endpoint', required=False, help="API endpoint", type=click.STRING) @click.option('--jwt', required=False, help="Enable jwt, by default is false", type=click.BOOL) @click.option('--force', is_flag=True, help="Force update profile name without confirmation") def update_profile(profile_name, region, endpoint, jwt, new_name, force): @@ -98,7 +98,7 @@ def update_profile(profile_name, region, endpoint, jwt, new_name, force): click.echo(msg) @profile.command('delete', help="Delete a profile by name") -@click.option('--profile-name', '--profile', '-pr', required=True, help="Name of profile", type=click.STRING) +@click.option('--profile-name', '--profile', required=True, help="Name of profile", type=click.STRING) @click.option('--force', '-f', is_flag=True, help="Force deletion without confirmation") def delete_profile(profile_name, force): """Delete a profile with confirmation.""" diff --git a/oks_cli/project.py b/oks_cli/project.py index 45af2a5..281c134 100644 --- a/oks_cli/project.py +++ b/oks_cli/project.py @@ -12,7 +12,7 @@ @click.group(help="Project related commands.") @click.option('--project', 'project_name', required = False, help="Project Name") @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project(ctx, project_name, profile): """Group of commands related to project management.""" @@ -21,7 +21,7 @@ def project(ctx, project_name, profile): # LOGIN ON PROJECT @project.command('login', help="Set a default project by name") @click.option('--project-name', '-p', required=False, help="Name of project", type=click.STRING, shell_complete=project_completer) -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_login(ctx, project_name, profile): """Set a default project by its name and log in.""" @@ -46,7 +46,7 @@ def project_login(ctx, project_name, profile): # LOGOUT ON PROJECT @project.command('logout', help="Unset default project") -@click.option("--profile", '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_logout(ctx, profile): """Unset the current default project and log out.""" @@ -60,12 +60,12 @@ def project_logout(ctx, profile): @project.command('list', help="List all projects") @click.option('--project-name', '-p', help="Name of project", type=click.STRING, shell_complete=project_completer) @click.option('--deleted', '-x', is_flag=True, help="List deleted projects") -@click.option('--plain', '-pl', is_flag=True, help="Plain table format") -@click.option('--msword', '-mw', is_flag=True, help="Microsoft Word table format") +@click.option('--plain', is_flag=True, help="Plain table format") +@click.option('--msword', is_flag=True, help="Microsoft Word table format") @click.option('--uuid', is_flag=True, help="Show UUID") @click.option('--watch', '-w', is_flag=True, help="Watch the changes") @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('--profile', '-pr', help="Configuration profile to use") +@click.option('--profile', help="Configuration profile to use") @click.pass_context def project_list(ctx, project_name, deleted, plain, msword, uuid, watch, output, profile): """List projects with filtering, formatting, and live watch capabilities.""" @@ -202,7 +202,7 @@ def format_row(project): @click.option('--dry-run', is_flag=True, help="Client dry-run, only print the object that would be sent, without sending it") @click.option('--output', '-o', type=click.Choice(["json", "yaml", "silent"]), help="Specify output format, by default is json") @click.option('--filename', '-f', type=click.File("r"), help="Path to file to use to create the project") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_create(ctx, project_name, description, cidr, quirk, tags, disable_api_termination, dry_run, output, filename, profile): """Create a new project from options or file, with support for dry-run and output formatting.""" @@ -256,7 +256,7 @@ def project_create(ctx, project_name, description, cidr, quirk, tags, disable_ap @project.command('get', help="Get default project or the project by name") @click.option('--project-name', '-p', help="Name of the project", shell_complete=project_completer) @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_get(ctx, project_name, output, profile): """Retrieve and display project details by name or default project.""" @@ -274,7 +274,7 @@ def project_get(ctx, project_name, output, profile): @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--dry-run', is_flag=True, help="Run without any action") @click.option('--force', is_flag=True, help="Force deletion without confirmation") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_delete_command(ctx, project_name, output, dry_run, force, profile): """Delete a project by name, with optional dry-run and confirmation.""" @@ -309,7 +309,7 @@ def project_delete_command(ctx, project_name, output, dry_run, force, profile): @click.option('--disable-api-termination', type=click.BOOL, help="Disable delete action by API") @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--dry-run', is_flag=True, help="Run without any action") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_update_command(ctx, project_name, description, quirk, tags, disable_api_termination, output, dry_run, profile): """Update project details by name, supporting dry-run and output formatting.""" @@ -352,7 +352,7 @@ def project_update_command(ctx, project_name, description, quirk, tags, disable_ @project.command('quotas', help="Get project quotas") @click.option('--project-name', '-p', help="Name of the project", shell_complete=project_completer) @click.option('--output', '-o', type=click.Choice(["json", "yaml", "table"]), help="Specify output format, by default is json") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_get_quotas(ctx, project_name, output, profile): """Retrieve resource quotas for the specified project.""" @@ -380,7 +380,7 @@ def project_get_quotas(ctx, project_name, output, profile): @project.command('snapshots', help="Get project snapshots") @click.option('--project-name', '-p', help="Name of the project", shell_complete=project_completer) @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_get(ctx, project_name, output, profile): """Retrieve snapshots associated with the specified project.""" @@ -396,7 +396,7 @@ def project_get(ctx, project_name, output, profile): @project.command('publicips', help="Get project public ips") @click.option('--project-name', '-p', help="Name of the project", shell_complete=project_completer) @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('--profile', '-pr',help="Configuration profile to use") +@click.option('--profile',help="Configuration profile to use") @click.pass_context def project_get_public_ips(ctx, project_name, output, profile): """Retrieve the list of public IPs associated with the specified project.""" diff --git a/oks_cli/quotas.py b/oks_cli/quotas.py index 3ec574d..62dd8f9 100644 --- a/oks_cli/quotas.py +++ b/oks_cli/quotas.py @@ -3,7 +3,7 @@ from .utils import do_request, print_output, print_table, ctx_update, login_profile, profile_completer @click.command(help="Get Quotas") -@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer) +@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) @click.option('--output','-o', type=click.Choice(["json", "yaml", "table"]), help="Specify output format, by default is json") @click.pass_context def quotas(ctx, profile, output): From 0be92716f13ec83004c87372e652b52426e8d75d Mon Sep 17 00:00:00 2001 From: Romain Demeure Date: Tue, 26 Aug 2025 11:06:59 +0200 Subject: [PATCH 3/3] :sparkles: feat: remove unnecessary shortcuts and remove shortcuts with two letters --- oks_cli/cache.py | 8 ++++---- oks_cli/cluster.py | 44 ++++++++++++++++++++++---------------------- oks_cli/main.py | 2 +- oks_cli/profile.py | 24 ++++++++++++------------ oks_cli/project.py | 26 +++++++++++++------------- oks_cli/quotas.py | 2 +- 6 files changed, 53 insertions(+), 53 deletions(-) diff --git a/oks_cli/cache.py b/oks_cli/cache.py index 1b60009..5301c4a 100644 --- a/oks_cli/cache.py +++ b/oks_cli/cache.py @@ -6,7 +6,7 @@ @click.group(help="Cache related commands.") @click.option('--project-name', '-p', required = False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required = False, help="Cluster Name", shell_complete=cluster_completer) -@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer) +@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cache(ctx, project_name, cluster_name, profile): """CLI command group for cache-related operations.""" @@ -22,9 +22,9 @@ def delete_cache(force): @cache.command('kubeconfigs', help="List cached kubeconfigs") @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) -@click.option('--plain', '-pl', is_flag=True, help="Plain table format") -@click.option('--msword', '-mw', is_flag=True, help="Microsoft Word table format") -@click.option('--profile', "-pr", help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--plain', is_flag=True, help="Plain table format") +@click.option('--msword', is_flag=True, help="Microsoft Word table format") +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def list_kubeconfigs(ctx, project_name, cluster_name, plain, msword, profile): """Display cached kubeconfigs with expiration dates in table format.""" diff --git a/oks_cli/cluster.py b/oks_cli/cluster.py index 14d8899..d0bcf6a 100644 --- a/oks_cli/cluster.py +++ b/oks_cli/cluster.py @@ -21,7 +21,7 @@ @click.group(help="Cluster related commands.") @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) -@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer) +@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster(ctx, project_name, cluster_name, profile): """Group of commands related to cluster management.""" @@ -30,7 +30,7 @@ def cluster(ctx, project_name, cluster_name, profile): # LOGIN ON CLUSTER @cluster.command('login', help="Set a default cluster") @click.option('--cluster-name', '--name', '-c', required=False, help="Name of cluster", shell_complete=cluster_completer) -@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer) +@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_login(ctx, cluster_name, profile): """Set the specified cluster as the default active cluster.""" @@ -57,7 +57,7 @@ def cluster_login(ctx, cluster_name, profile): # LOGOUT ON CLUSTER @cluster.command('logout', help="Unset default cluster") -@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer) +@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_logout(ctx, profile): """Clear the current default cluster selection.""" @@ -71,11 +71,11 @@ def cluster_logout(ctx, profile): @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) @click.option('--deleted', '-x', is_flag=True, help="List deleted clusters") # x pour "deleted" / "removed" -@click.option('--plain', '-pl', is_flag=True, help="Plain table format") -@click.option('--msword', '-mw', is_flag=True, help="Microsoft Word table format") +@click.option('--plain', is_flag=True, help="Plain table format") +@click.option('--msword', is_flag=True, help="Microsoft Word table format") @click.option('--watch', '-w', is_flag=True, help="Watch the changes") @click.option('--output', '-o', type=click.Choice(["json", "yaml", "wide"]), help="Specify output format") -@click.option('--profile', '-pr', help="Configuration profile to use") +@click.option('--profile', help="Configuration profile to use") @click.pass_context def cluster_list(ctx, project_name, cluster_name, deleted, plain, msword, watch, output, profile): """Display clusters with optional filtering and real-time monitoring.""" @@ -215,7 +215,7 @@ def format_row(cluster): @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_get_command(ctx, project_name, cluster_name, output, profile): """Retrieve and display detailed information about a specific cluster.""" @@ -325,7 +325,7 @@ def _create_cluster(project_name, cluster_config, output): @click.option('--dry-run', is_flag=True, help="Client dry-run, only print the object that would be sent, without sending it") @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--filename', '-f', type=click.File("r"), help="Path to file to use to create the cluster ") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_create_command(ctx, project_name, cluster_name, description, admin, version, cidr_pods, cidr_service, control_plane, zone, enable_admission_plugins, disable_admission_plugins, quirk, tags, disable_api_termination, cp_multi_az, dry_run, output, filename, profile): """CLI command to create a new Kubernetes cluster with optional configuration parameters.""" @@ -421,7 +421,7 @@ def cluster_create_command(ctx, project_name, cluster_name, description, admin, @click.option('--dry-run', is_flag=True, help="Client dry-run, only print the object that would be sent, without sending it") @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--filename', '-f', type=click.File("r"), help="Path to file to use to update the cluster ") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_update_command(ctx, project_name, cluster_name, description, admin, version, tags, enable_admission_plugins, disable_admission_plugins, quirk, disable_api_termination, control_plane, dry_run, output, filename, profile): """CLI command to update an existing Kubernetes cluster with new configuration options.""" @@ -498,7 +498,7 @@ def cluster_update_command(ctx, project_name, cluster_name, description, admin, @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster name", shell_complete=cluster_completer) @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--force', is_flag=True, help="Force upgrade") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_update_command(ctx, project_name, cluster_name, output, force, profile): """CLI command to upgrade an existing Kubernetes cluster to the latest supported version.""" @@ -520,7 +520,7 @@ def cluster_update_command(ctx, project_name, cluster_name, output, force, profi @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--dry-run', is_flag=True, help="Run without any action") @click.option('--force', is_flag=True, help="Force deletion without confirmation") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_delete_command(ctx, project_name, cluster_name, output, dry_run, force, profile): """CLI command to delete an existing Kubernetes cluster by name.""" @@ -548,13 +548,13 @@ def cluster_delete_command(ctx, project_name, cluster_name, output, dry_run, for @cluster.command('kubeconfig', help="Fetch the kubeconfig for a cluster") @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) -@click.option('--print-path', '-pp', is_flag=True, help="Print path to saved kubeconfig") +@click.option('--print-path', is_flag=True, help="Print path to saved kubeconfig") @click.option('--refresh', '--force', is_flag=True, help="Force refresh saved kubeconfig") @click.option('--nacl', is_flag=True, help="Use public key encryption on wire (require api support)") -@click.option('--user', '-u', type=click.STRING, help="User") -@click.option('--group', '-g', type=click.STRING, help="Group") -@click.option('--ttl', '-t', type=click.STRING, help="TTL in human readable format (5h, 1d, 1w)") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--user', type=click.STRING, help="User") +@click.option('--group', type=click.STRING, help="Group") +@click.option('--ttl', type=click.STRING, help="TTL in human readable format (5h, 1d, 1w)") +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def cluster_kubeconfig_command(ctx, project_name, cluster_name, print_path, refresh, nacl, user, group, ttl, profile): """CLI command to fetch and optionally print the kubeconfig for a specified cluster.""" @@ -657,9 +657,9 @@ def _run_kubectl(project_id, cluster_id, user, group, args, input=None): @cluster.command('kubectl', help='Fetch the kubeconfig for a cluster and run kubectl against it', context_settings={"ignore_unknown_options": True}) @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) -@click.option('--user', '-u', type=click.STRING, help="User") -@click.option('--group', '-g', type=click.STRING, help="Group") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--user', type=click.STRING, help="User") +@click.option('--group', type=click.STRING, help="Group") +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.argument("args", nargs=-1, type=click.UNPROCESSED) @click.pass_context def cluster_kubectl_command(ctx, project_name, cluster_name, user, group, args, profile): @@ -676,9 +676,9 @@ def cluster_kubectl_command(ctx, project_name, cluster_name, user, group, args, @click.group(help="Nodepool related commands.") @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) -@click.option('--user', '-u', type=click.STRING, help="User") -@click.option('--group', '-g', type=click.STRING, help="Group") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--user', type=click.STRING, help="User") +@click.option('--group', type=click.STRING, help="Group") +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def nodepool(ctx, project_name, cluster_name, user, group, profile): """CLI group for nodepool-related commands, managing project, cluster, user, and profile context.""" diff --git a/oks_cli/main.py b/oks_cli/main.py index ccbff28..8ee69b4 100755 --- a/oks_cli/main.py +++ b/oks_cli/main.py @@ -13,7 +13,7 @@ # Main CLI entry point @click.group(invoke_without_command=True) -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) @click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer) @click.option('--verbose', '-v', count=True, help="Increase verbosity") diff --git a/oks_cli/profile.py b/oks_cli/profile.py index ddf29d5..dbe42d3 100644 --- a/oks_cli/profile.py +++ b/oks_cli/profile.py @@ -11,13 +11,13 @@ def profile(): @profile.command('add', help="Add AK/SK or username/password new profile") -@click.option('--profile-name', '--profile', '-pr', required=False, help="Name of profile, optional", type=click.STRING) -@click.option('--access-key', '-ak', required=False, help="AK of profile", type=click.STRING) -@click.option('--secret-key', '-sk', required=False, help="SK of profile", type=click.STRING) -@click.option('--username', '-u', required=False, help="Username", type=click.STRING) -@click.option('--password', '-p', required=False, help="Password", type=click.STRING) -@click.option('--region', '-r', required=True, help="Region name", type=click.Choice(['eu-west-2', 'cloudgouv-eu-west-1'])) -@click.option('--endpoint', '-e', required=False, help="API endpoint", type=click.STRING) +@click.option('--profile-name', '--profile', required=False, help="Name of profile, optional", type=click.STRING) +@click.option('--access-key', required=False, help="AK of profile", type=click.STRING) +@click.option('--secret-key', required=False, help="SK of profile", type=click.STRING) +@click.option('--username', required=False, help="Username", type=click.STRING) +@click.option('--password', required=False, help="Password", type=click.STRING) +@click.option('--region', required=True, help="Region name", type=click.Choice(['eu-west-2', 'cloudgouv-eu-west-1'])) +@click.option('--endpoint', required=False, help="API endpoint", type=click.STRING) @click.option('--jwt', help="Enable JWT, by default is false") def add_profile(profile_name, access_key, secret_key, username, password, region, endpoint, jwt): """Add a new profile with AK/SK or username/password authentication.""" @@ -62,10 +62,10 @@ def add_profile(profile_name, access_key, secret_key, username, password, region click.echo(f"Profile {profile_name_styled} has been successfully added") @profile.command('update', help="Update an existing profile") -@click.option('--profile-name', '-pr', required=True, help="Name of profile", type=click.STRING) +@click.option('--profile-name', required=True, help="Name of profile", type=click.STRING) @click.option('--new-name', required=False, help="Update profile name with new one, USE IT WITH CAUTION", type=click.STRING) -@click.option('--region', '-r', required=False, help="Region name", type=click.Choice(['eu-west-2', 'cloudgouv-eu-west-1'])) -@click.option('--endpoint', '-e', required=False, help="API endpoint", type=click.STRING) +@click.option('--region', required=False, help="Region name", type=click.Choice(['eu-west-2', 'cloudgouv-eu-west-1'])) +@click.option('--endpoint', required=False, help="API endpoint", type=click.STRING) @click.option('--jwt', required=False, help="Enable jwt, by default is false", type=click.BOOL) @click.option('--force', is_flag=True, help="Force update profile name without confirmation") def update_profile(profile_name, region, endpoint, jwt, new_name, force): @@ -98,8 +98,8 @@ def update_profile(profile_name, region, endpoint, jwt, new_name, force): click.echo(msg) @profile.command('delete', help="Delete a profile by name") -@click.option('--profile-name', '--profile', '-pr', required=True, help="Name of profile", type=click.STRING) -@click.option('--force', '-f', is_flag=True, help="Force deletion without confirmation") +@click.option('--profile-name', '--profile', required=True, help="Name of profile", type=click.STRING) +@click.option('--force', is_flag=True, help="Force deletion without confirmation") def delete_profile(profile_name, force): """Delete a profile with confirmation.""" profiles = profile_list() diff --git a/oks_cli/project.py b/oks_cli/project.py index 45af2a5..281c134 100644 --- a/oks_cli/project.py +++ b/oks_cli/project.py @@ -12,7 +12,7 @@ @click.group(help="Project related commands.") @click.option('--project', 'project_name', required = False, help="Project Name") @click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer) -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project(ctx, project_name, profile): """Group of commands related to project management.""" @@ -21,7 +21,7 @@ def project(ctx, project_name, profile): # LOGIN ON PROJECT @project.command('login', help="Set a default project by name") @click.option('--project-name', '-p', required=False, help="Name of project", type=click.STRING, shell_complete=project_completer) -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_login(ctx, project_name, profile): """Set a default project by its name and log in.""" @@ -46,7 +46,7 @@ def project_login(ctx, project_name, profile): # LOGOUT ON PROJECT @project.command('logout', help="Unset default project") -@click.option("--profile", '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_logout(ctx, profile): """Unset the current default project and log out.""" @@ -60,12 +60,12 @@ def project_logout(ctx, profile): @project.command('list', help="List all projects") @click.option('--project-name', '-p', help="Name of project", type=click.STRING, shell_complete=project_completer) @click.option('--deleted', '-x', is_flag=True, help="List deleted projects") -@click.option('--plain', '-pl', is_flag=True, help="Plain table format") -@click.option('--msword', '-mw', is_flag=True, help="Microsoft Word table format") +@click.option('--plain', is_flag=True, help="Plain table format") +@click.option('--msword', is_flag=True, help="Microsoft Word table format") @click.option('--uuid', is_flag=True, help="Show UUID") @click.option('--watch', '-w', is_flag=True, help="Watch the changes") @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('--profile', '-pr', help="Configuration profile to use") +@click.option('--profile', help="Configuration profile to use") @click.pass_context def project_list(ctx, project_name, deleted, plain, msword, uuid, watch, output, profile): """List projects with filtering, formatting, and live watch capabilities.""" @@ -202,7 +202,7 @@ def format_row(project): @click.option('--dry-run', is_flag=True, help="Client dry-run, only print the object that would be sent, without sending it") @click.option('--output', '-o', type=click.Choice(["json", "yaml", "silent"]), help="Specify output format, by default is json") @click.option('--filename', '-f', type=click.File("r"), help="Path to file to use to create the project") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_create(ctx, project_name, description, cidr, quirk, tags, disable_api_termination, dry_run, output, filename, profile): """Create a new project from options or file, with support for dry-run and output formatting.""" @@ -256,7 +256,7 @@ def project_create(ctx, project_name, description, cidr, quirk, tags, disable_ap @project.command('get', help="Get default project or the project by name") @click.option('--project-name', '-p', help="Name of the project", shell_complete=project_completer) @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_get(ctx, project_name, output, profile): """Retrieve and display project details by name or default project.""" @@ -274,7 +274,7 @@ def project_get(ctx, project_name, output, profile): @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--dry-run', is_flag=True, help="Run without any action") @click.option('--force', is_flag=True, help="Force deletion without confirmation") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_delete_command(ctx, project_name, output, dry_run, force, profile): """Delete a project by name, with optional dry-run and confirmation.""" @@ -309,7 +309,7 @@ def project_delete_command(ctx, project_name, output, dry_run, force, profile): @click.option('--disable-api-termination', type=click.BOOL, help="Disable delete action by API") @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") @click.option('--dry-run', is_flag=True, help="Run without any action") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_update_command(ctx, project_name, description, quirk, tags, disable_api_termination, output, dry_run, profile): """Update project details by name, supporting dry-run and output formatting.""" @@ -352,7 +352,7 @@ def project_update_command(ctx, project_name, description, quirk, tags, disable_ @project.command('quotas', help="Get project quotas") @click.option('--project-name', '-p', help="Name of the project", shell_complete=project_completer) @click.option('--output', '-o', type=click.Choice(["json", "yaml", "table"]), help="Specify output format, by default is json") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_get_quotas(ctx, project_name, output, profile): """Retrieve resource quotas for the specified project.""" @@ -380,7 +380,7 @@ def project_get_quotas(ctx, project_name, output, profile): @project.command('snapshots', help="Get project snapshots") @click.option('--project-name', '-p', help="Name of the project", shell_complete=project_completer) @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer) +@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer) @click.pass_context def project_get(ctx, project_name, output, profile): """Retrieve snapshots associated with the specified project.""" @@ -396,7 +396,7 @@ def project_get(ctx, project_name, output, profile): @project.command('publicips', help="Get project public ips") @click.option('--project-name', '-p', help="Name of the project", shell_complete=project_completer) @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json") -@click.option('--profile', '-pr',help="Configuration profile to use") +@click.option('--profile',help="Configuration profile to use") @click.pass_context def project_get_public_ips(ctx, project_name, output, profile): """Retrieve the list of public IPs associated with the specified project.""" diff --git a/oks_cli/quotas.py b/oks_cli/quotas.py index 3ec574d..62dd8f9 100644 --- a/oks_cli/quotas.py +++ b/oks_cli/quotas.py @@ -3,7 +3,7 @@ from .utils import do_request, print_output, print_table, ctx_update, login_profile, profile_completer @click.command(help="Get Quotas") -@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer) +@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer) @click.option('--output','-o', type=click.Choice(["json", "yaml", "table"]), help="Specify output format, by default is json") @click.pass_context def quotas(ctx, profile, output):