Skip to content

Commit 1c76bc2

Browse files
authored
fix: docs cli publish (#1115)
1 parent 3537621 commit 1c76bc2

File tree

1 file changed

+36
-26
lines changed

1 file changed

+36
-26
lines changed

src/uipath/_cli/__init__.py

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,39 @@
1919
# We spent hours getting startup from 1.7s → 0.5s.
2020
# If you add `import pandas` here, I will find you.
2121

22+
_LAZY_COMMANDS = {
23+
"new": "cli_new",
24+
"init": "cli_init",
25+
"pack": "cli_pack",
26+
"publish": "cli_publish",
27+
"run": "cli_run",
28+
"deploy": "cli_deploy",
29+
"auth": "cli_auth",
30+
"invoke": "cli_invoke",
31+
"push": "cli_push",
32+
"pull": "cli_pull",
33+
"eval": "cli_eval",
34+
"dev": "cli_dev",
35+
"add": "cli_add",
36+
"register": "cli_register",
37+
"debug": "cli_debug",
38+
"buckets": "services.cli_buckets",
39+
}
40+
41+
42+
def _load_command(name: str):
43+
"""Load a CLI command by name."""
44+
if name not in _LAZY_COMMANDS:
45+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
46+
module_name = _LAZY_COMMANDS[name]
47+
mod = __import__(f"uipath._cli.{module_name}", fromlist=[name])
48+
return getattr(mod, name)
49+
50+
51+
def __getattr__(name: str):
52+
"""Lazy load CLI commands for mkdocs-click compatibility."""
53+
return _load_command(name)
54+
2255

2356
def add_cwd_to_path():
2457
cwd = os.getcwd()
@@ -48,35 +81,12 @@ def _get_safe_version() -> str:
4881
class LazyGroup(click.Group):
4982
"""Lazy-load commands only when invoked."""
5083

51-
def __init__(self, *args, **kwargs):
52-
super().__init__(*args, **kwargs)
53-
self._lazy_commands = {
54-
"new": "cli_new",
55-
"init": "cli_init",
56-
"pack": "cli_pack",
57-
"publish": "cli_publish",
58-
"run": "cli_run",
59-
"deploy": "cli_deploy",
60-
"auth": "cli_auth",
61-
"invoke": "cli_invoke",
62-
"push": "cli_push",
63-
"pull": "cli_pull",
64-
"eval": "cli_eval",
65-
"dev": "cli_dev",
66-
"add": "cli_add",
67-
"register": "cli_register",
68-
"debug": "cli_debug",
69-
"buckets": "services.cli_buckets",
70-
}
71-
7284
def list_commands(self, ctx):
73-
return sorted(self._lazy_commands.keys())
85+
return sorted(_LAZY_COMMANDS.keys())
7486

7587
def get_command(self, ctx, cmd_name):
76-
if cmd_name in self._lazy_commands:
77-
module_name = self._lazy_commands[cmd_name]
78-
mod = __import__(f"uipath._cli.{module_name}", fromlist=[cmd_name])
79-
return getattr(mod, cmd_name)
88+
if cmd_name in _LAZY_COMMANDS:
89+
return _load_command(cmd_name)
8090
return None
8191

8292

0 commit comments

Comments
 (0)