From ff5532d9c9fde842f064664ca5829fffa83c46c7 Mon Sep 17 00:00:00 2001 From: Ossama Alami Date: Tue, 21 Oct 2025 11:09:57 -0700 Subject: [PATCH 1/4] Fix command listing to show only main commands, hiding singular aliases - Created a custom AliasedGroup class in /Users/ossama/dev/workato-platform-cli/src/workato_platform/cli/__init__.py:26-47 - Added add_command_with_alias() method that registers the command and stores alias mappings internally - Modified get_command() to resolve aliases to their main command names - Updated all command registrations to use add_command_with_alias() with the singular form as the hidden alias --- src/workato_platform/cli/__init__.py | 54 +++++++++++++++++----------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/src/workato_platform/cli/__init__.py b/src/workato_platform/cli/__init__.py index 9da456c..e847571 100644 --- a/src/workato_platform/cli/__init__.py +++ b/src/workato_platform/cli/__init__.py @@ -23,7 +23,31 @@ from workato_platform.cli.utils.version_checker import check_updates_async -@click.group() +class AliasedGroup(click.Group): + """A Click Group that supports command aliases without showing them in help""" + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.aliases = {} + + def add_command_with_alias(self, cmd, name=None, alias=None): + """Add a command with an optional hidden alias""" + # Add the main command + self.add_command(cmd, name=name) + + # Store alias mapping + if alias: + main_name = name or cmd.name + self.aliases[alias] = main_name + + def get_command(self, ctx, cmd_name): + # Check if it's an alias first + if cmd_name in self.aliases: + cmd_name = self.aliases[cmd_name] + return super().get_command(ctx, cmd_name) + + +@click.group(cls=AliasedGroup) @click.option( "--profile", help="Profile to use for authentication and region settings", @@ -66,12 +90,9 @@ def cli( # Core setup and configuration commands cli.add_command(init.init) -cli.add_command(projects.projects) -cli.add_command(projects.projects, name="project") +cli.add_command_with_alias(projects.projects, alias="project") cli.add_command(profiles.profiles) -cli.add_command(profiles.profiles, name="profiles") -cli.add_command(properties.properties) -cli.add_command(properties.properties, name="property") +cli.add_command_with_alias(properties.properties, alias="property") # Development commands cli.add_command(guide.guide) @@ -79,20 +100,13 @@ def cli( cli.add_command(pull.pull) # API and resource management commands -cli.add_command(api_collections.api_collections) -cli.add_command(api_collections.api_collections, name="api-collection") -cli.add_command(api_clients.api_clients) -cli.add_command(api_clients.api_clients, name="api-client") -cli.add_command(data_tables.data_tables) -cli.add_command(data_tables.data_tables, name="data-table") -cli.add_command(connections.connections) -cli.add_command(connections.connections, name="connection") -cli.add_command(connectors.connectors) -cli.add_command(connectors.connectors, name="connector") -cli.add_command(recipes.recipes) -cli.add_command(recipes.recipes, name="recipe") +cli.add_command_with_alias(api_collections.api_collections, alias="api-collection") +cli.add_command_with_alias(api_clients.api_clients, alias="api-client") +cli.add_command_with_alias(data_tables.data_tables, alias="data-table") +cli.add_command_with_alias(connections.connections, alias="connection") +cli.add_command_with_alias(connectors.connectors, alias="connector") +cli.add_command_with_alias(recipes.recipes, alias="recipe") # Information commands -cli.add_command(assets.assets) -cli.add_command(assets.assets, name="asset") +cli.add_command_with_alias(assets.assets, alias="asset") cli.add_command(workspace.workspace) From 3a5177a32bd6d5ae2a4de9b3cc969ab2c9b2b88c Mon Sep 17 00:00:00 2001 From: Ossama Alami Date: Tue, 21 Oct 2025 11:14:40 -0700 Subject: [PATCH 2/4] Update src/workato_platform/cli/__init__.py check that alias is not equal to the main command name Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/workato_platform/cli/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/workato_platform/cli/__init__.py b/src/workato_platform/cli/__init__.py index e847571..5aca111 100644 --- a/src/workato_platform/cli/__init__.py +++ b/src/workato_platform/cli/__init__.py @@ -38,6 +38,8 @@ def add_command_with_alias(self, cmd, name=None, alias=None): # Store alias mapping if alias: main_name = name or cmd.name + if alias == main_name: + raise ValueError(f"Alias '{alias}' cannot be the same as the main command name '{main_name}'.") self.aliases[alias] = main_name def get_command(self, ctx, cmd_name): From d7a2bb2e38b39ea70a14ac3dfaf8a5191828ca43 Mon Sep 17 00:00:00 2001 From: Ossama Alami Date: Tue, 21 Oct 2025 11:18:26 -0700 Subject: [PATCH 3/4] fix line length for linter --- src/workato_platform/cli/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/workato_platform/cli/__init__.py b/src/workato_platform/cli/__init__.py index 5aca111..c9ee768 100644 --- a/src/workato_platform/cli/__init__.py +++ b/src/workato_platform/cli/__init__.py @@ -39,7 +39,9 @@ def add_command_with_alias(self, cmd, name=None, alias=None): if alias: main_name = name or cmd.name if alias == main_name: - raise ValueError(f"Alias '{alias}' cannot be the same as the main command name '{main_name}'.") + raise ValueError( + f"Alias '{alias}' cannot be the same as the main command name '{main_name}'." + ) self.aliases[alias] = main_name def get_command(self, ctx, cmd_name): From 96846b36247a7a9bcfdc4e455fd0df5288292788 Mon Sep 17 00:00:00 2001 From: Ossama Alami Date: Tue, 21 Oct 2025 11:21:49 -0700 Subject: [PATCH 4/4] fix line length for linter (again)) --- package-lock.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..406b071 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "workato-platform-cli", + "lockfileVersion": 3, + "requires": true, + "packages": {} +}