compshare-cli 0.1.0__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/PKG-INFO +2 -1
  2. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/pyproject.toml +2 -1
  3. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/__init__.py +1 -1
  4. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/cli.py +10 -2
  5. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/i18n.py +3 -2
  6. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli.egg-info/PKG-INFO +2 -1
  7. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli.egg-info/requires.txt +1 -0
  8. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/tests/test_cli.py +13 -5
  9. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/README.md +0 -0
  10. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/setup.cfg +0 -0
  11. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/__main__.py +0 -0
  12. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/actions.py +0 -0
  13. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/api.py +0 -0
  14. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/commands/__init__.py +0 -0
  15. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/commands/common.py +0 -0
  16. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/commands/image.py +0 -0
  17. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/commands/instance.py +0 -0
  18. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/commands/storage.py +0 -0
  19. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/config.py +0 -0
  20. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/errors.py +0 -0
  21. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/location.py +0 -0
  22. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/output.py +0 -0
  23. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/parsing.py +0 -0
  24. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/runtime.py +0 -0
  25. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli/sdk.py +0 -0
  26. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli.egg-info/SOURCES.txt +0 -0
  27. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli.egg-info/dependency_links.txt +0 -0
  28. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli.egg-info/entry_points.txt +0 -0
  29. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/src/compshare_cli.egg-info/top_level.txt +0 -0
  30. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/tests/test_actions.py +0 -0
  31. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/tests/test_config.py +0 -0
  32. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/tests/test_location.py +0 -0
  33. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/tests/test_output.py +0 -0
  34. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/tests/test_parsing.py +0 -0
  35. {compshare_cli-0.1.0 → compshare_cli-0.1.2}/tests/test_sdk.py +0 -0
@@ -1,11 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compshare-cli
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Command-line client for CompShare GPU compute
5
5
  Author: CompShare
6
6
  License: Apache-2.0
7
7
  Requires-Python: >=3.9
8
8
  Description-Content-Type: text/markdown
9
+ Requires-Dist: click<9,>=8.1
9
10
  Requires-Dist: rich<15,>=13
10
11
  Requires-Dist: typer<1,>=0.12
11
12
  Requires-Dist: ucloud-sdk-python3<0.12,>=0.11.103
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "compshare-cli"
7
- version = "0.1.0"
7
+ version = "0.1.2"
8
8
  description = "Command-line client for CompShare GPU compute"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -13,6 +13,7 @@ authors = [
13
13
  { name = "CompShare" },
14
14
  ]
15
15
  dependencies = [
16
+ "click>=8.1,<9",
16
17
  "rich>=13,<15",
17
18
  "typer>=0.12,<1",
18
19
  "ucloud-sdk-python3>=0.11.103,<0.12",
@@ -1,3 +1,3 @@
1
1
  """CompShare command-line client."""
2
2
 
3
- __version__ = "0.1.0"
3
+ __version__ = "0.1.2"
@@ -5,6 +5,7 @@ from typing import List, Optional
5
5
 
6
6
  import click
7
7
  import typer
8
+ from typer import core as typer_core
8
9
  from typer.main import get_command
9
10
 
10
11
  from compshare_cli import __version__
@@ -15,6 +16,11 @@ from compshare_cli.i18n import configured_language, localize_command, normalize_
15
16
  from compshare_cli.output import Renderer
16
17
  from compshare_cli.runtime import Runtime
17
18
 
19
+ _TYPER_CLICK = getattr(typer_core, "_click", click)
20
+ _TYPER_CLICK_EXCEPTIONS = getattr(_TYPER_CLICK, "exceptions", _TYPER_CLICK)
21
+ _CLICK_EXCEPTIONS = (click.ClickException, _TYPER_CLICK_EXCEPTIONS.ClickException)
22
+ _ABORT_EXCEPTIONS = (click.Abort, _TYPER_CLICK_EXCEPTIONS.Abort)
23
+
18
24
  app = typer.Typer(
19
25
  name="compshare",
20
26
  help="Manage CompShare GPU compute from the terminal.",
@@ -198,6 +204,8 @@ def lang(
198
204
 
199
205
  def main(args: Optional[List[str]] = None) -> None:
200
206
  argv = list(sys.argv[1:] if args is None else args)
207
+ if not argv:
208
+ argv = ["-h"]
201
209
  try:
202
210
  language = configured_language()
203
211
  command = localize_command(get_command(app), language)
@@ -205,10 +213,10 @@ def main(args: Optional[List[str]] = None) -> None:
205
213
  except CLIError as error:
206
214
  Renderer("--json" in argv).error(str(error))
207
215
  raise SystemExit(2) from error
208
- except click.ClickException as error:
216
+ except _CLICK_EXCEPTIONS as error:
209
217
  Renderer("--json" in argv).error(error.format_message())
210
218
  raise SystemExit(error.exit_code) from error
211
- except click.Abort as error:
219
+ except _ABORT_EXCEPTIONS as error:
212
220
  Renderer("--json" in argv).error(tr("Aborted"))
213
221
  raise SystemExit(1) from error
214
222
  if isinstance(result, int) and result:
@@ -500,7 +500,8 @@ def localize_command(command: click.Command, language: str) -> click.Command:
500
500
  return option
501
501
 
502
502
  command.get_help_option = localized_help_option # type: ignore[method-assign]
503
- if isinstance(command, click.Group):
504
- for child in command.commands.values():
503
+ children = getattr(command, "commands", None)
504
+ if children is not None:
505
+ for child in children.values():
505
506
  localize_command(child, language)
506
507
  return command
@@ -1,11 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compshare-cli
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Command-line client for CompShare GPU compute
5
5
  Author: CompShare
6
6
  License: Apache-2.0
7
7
  Requires-Python: >=3.9
8
8
  Description-Content-Type: text/markdown
9
+ Requires-Dist: click<9,>=8.1
9
10
  Requires-Dist: rich<15,>=13
10
11
  Requires-Dist: typer<1,>=0.12
11
12
  Requires-Dist: ucloud-sdk-python3<0.12,>=0.11.103
@@ -1,3 +1,4 @@
1
+ click<9,>=8.1
1
2
  rich<15,>=13
2
3
  typer<1,>=0.12
3
4
  ucloud-sdk-python3<0.12,>=0.11.103
@@ -1,6 +1,5 @@
1
1
  import json
2
2
 
3
- import click
4
3
  import pytest
5
4
  from typer.main import get_command
6
5
  from typer.testing import CliRunner
@@ -30,12 +29,19 @@ def test_help_tree(args) -> None:
30
29
 
31
30
  def test_global_json_is_accepted_before_command(capsys) -> None:
32
31
  cli.main(["--json", "version"])
33
- assert json.loads(capsys.readouterr().out) == {"version": "0.1.0"}
32
+ assert json.loads(capsys.readouterr().out) == {"version": "0.1.2"}
34
33
 
35
34
 
36
35
  def test_global_profile_is_accepted_before_command(capsys) -> None:
37
36
  cli.main(["--profile", "testing", "--json", "version"])
38
- assert json.loads(capsys.readouterr().out) == {"version": "0.1.0"}
37
+ assert json.loads(capsys.readouterr().out) == {"version": "0.1.2"}
38
+
39
+
40
+ def test_no_args_shows_help_without_error(capsys) -> None:
41
+ cli.main([])
42
+ captured = capsys.readouterr()
43
+ assert "Usage:" in captured.out
44
+ assert "Traceback" not in captured.err
39
45
 
40
46
 
41
47
  def test_global_options_after_command_are_rejected(capsys) -> None:
@@ -107,6 +113,7 @@ def test_lang_command_persists_help_language(monkeypatch, tmp_path, capsys) -> N
107
113
  cli.main(["--help"])
108
114
  chinese = capsys.readouterr().out
109
115
  assert "在终端管理优云智算 GPU 计算资源" in chinese
116
+ assert "管理 GPU 实例" in chinese
110
117
  assert "显示帮助并退出" in chinese
111
118
  assert "--install-completion" not in chinese
112
119
  assert "--lang" not in chinese
@@ -157,8 +164,9 @@ def test_every_command_has_chinese_and_english_description() -> None:
157
164
 
158
165
  def descriptions(command, prefix=()):
159
166
  result = []
160
- if isinstance(command, click.Group):
161
- for name, child in command.commands.items():
167
+ children = getattr(command, "commands", None)
168
+ if children is not None:
169
+ for name, child in children.items():
162
170
  path = (*prefix, name)
163
171
  result.append((path, child.help or child.short_help))
164
172
  result.extend(descriptions(child, path))
File without changes
File without changes