From e3885f4fddc14ba4f8b0dee0df9f54b85d1ef3bf Mon Sep 17 00:00:00 2001 From: memsharded Date: Fri, 7 Aug 2026 18:32:19 +0200 Subject: [PATCH] workspace alias cmd --- conan/cli/cli.py | 4 ++++ test/integration/workspace/test_workspace.py | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/conan/cli/cli.py b/conan/cli/cli.py index 88a6a982786..28f0676dd8b 100644 --- a/conan/cli/cli.py +++ b/conan/cli/cli.py @@ -20,6 +20,9 @@ _CONAN_INTERNAL_CUSTOM_COMMANDS_PATH = "_CONAN_INTERNAL_CUSTOM_COMMANDS_PATH" +# Short aliases mapped to their canonical command names +_COMMAND_ALIASES = {"ws": "workspace"} + class Cli: """A single command of the conan application, with all the first level commands. Manages the @@ -174,6 +177,7 @@ def run(self, *args): except IndexError: # No parameters self._output_help_cli() return + command_argument = _COMMAND_ALIASES.get(command_argument, command_argument) try: command = self._commands[command_argument] except KeyError as exc: diff --git a/test/integration/workspace/test_workspace.py b/test/integration/workspace/test_workspace.py index 1527936278c..fc0676ade29 100644 --- a/test/integration/workspace/test_workspace.py +++ b/test/integration/workspace/test_workspace.py @@ -15,6 +15,26 @@ from conan.tools.files import replace_in_file +class TestWorkspaceAlias: + + def test_ws_alias_dispatches_to_workspace(self): + # 'ws' behaves as 'workspace' for both the base command and its subcommands + c = TestClient(light=True) + c.save({"conanws.yml": ""}) + c.run("ws root") + assert c.current_folder in c.stdout + + c.run("ws info") + assert "packages: (empty)" in c.out + + def test_ws_alias_not_in_help_listing(self): + c = TestClient(light=True) + c.run("-h") + assert "workspace" in c.stdout + for line in c.stdout.splitlines(): + assert not line.strip().startswith("ws "), line + + class TestWorkspaceRoot: def test_workspace_root(self):