devnomads-cli 0.16.0__tar.gz → 0.16.1__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.
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/PKG-INFO +1 -1
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/devnomads_cli.egg-info/PKG-INFO +1 -1
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/dncli.py +49 -10
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/pyproject.toml +1 -1
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/tests/test_agent_features.py +19 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/tests/test_generate.py +15 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/tests/test_generated_cli.py +5 -1
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/LICENSE +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/README.md +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/devnomads_cli.egg-info/SOURCES.txt +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/devnomads_cli.egg-info/dependency_links.txt +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/devnomads_cli.egg-info/entry_points.txt +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/devnomads_cli.egg-info/requires.txt +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/devnomads_cli.egg-info/top_level.txt +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/setup.cfg +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/tests/test_cert.py +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/tests/test_cli.py +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/tests/test_config.py +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/tests/test_helpers.py +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/tests/test_hook.py +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/tests/test_sites_publish.py +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/tests/test_sites_ssh.py +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/tests/test_ssh_keys.py +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/tests/test_transfer.py +0 -0
- {devnomads_cli-0.16.0 → devnomads_cli-0.16.1}/tests/test_versions.py +0 -0
|
@@ -54,6 +54,8 @@ from typing import (
|
|
|
54
54
|
Literal,
|
|
55
55
|
Protocol,
|
|
56
56
|
TypeGuard,
|
|
57
|
+
get_args,
|
|
58
|
+
get_origin,
|
|
57
59
|
)
|
|
58
60
|
|
|
59
61
|
import httpx
|
|
@@ -70,7 +72,7 @@ from rich.markup import escape
|
|
|
70
72
|
from rich.table import Table
|
|
71
73
|
from typer.core import TyperGroup
|
|
72
74
|
|
|
73
|
-
__version__ = "0.16.
|
|
75
|
+
__version__ = "0.16.1"
|
|
74
76
|
|
|
75
77
|
# Distribution names, for reporting versions via `dncli version`.
|
|
76
78
|
CLI_PACKAGE = "devnomads-cli"
|
|
@@ -1650,6 +1652,45 @@ HANDWRITTEN_CHANGES = {
|
|
|
1650
1652
|
_CATALOG_SKIP = {"output", "columns", "timeout"}
|
|
1651
1653
|
|
|
1652
1654
|
|
|
1655
|
+
def _param_type(param: Any) -> tuple[str, list[Any] | None]:
|
|
1656
|
+
"""A parameter's type name and its choices (None unless it has them).
|
|
1657
|
+
|
|
1658
|
+
typer up to 0.28 builds a click type for every parameter (`param.type`).
|
|
1659
|
+
typer 0.29 dropped click's types: it keeps the Python annotation in
|
|
1660
|
+
`param.type_descriptor` and converts values itself, so read that."""
|
|
1661
|
+
|
|
1662
|
+
click_type = getattr(param, "type", None)
|
|
1663
|
+
if click_type is not None:
|
|
1664
|
+
choices = getattr(click_type, "choices", None)
|
|
1665
|
+
if choices is not None:
|
|
1666
|
+
return "choice", list(choices)
|
|
1667
|
+
name = click_type.name
|
|
1668
|
+
return {"integer": "int", "text": "str"}.get(name, name), None
|
|
1669
|
+
|
|
1670
|
+
descriptor = getattr(param, "type_descriptor", None)
|
|
1671
|
+
annotation = getattr(descriptor, "annotation", str)
|
|
1672
|
+
if get_origin(annotation) in (list, tuple) and get_args(annotation):
|
|
1673
|
+
annotation = get_args(annotation)[0] # a repeatable option
|
|
1674
|
+
if get_origin(annotation) is Literal:
|
|
1675
|
+
return "choice", list(get_args(annotation))
|
|
1676
|
+
if isinstance(annotation, type) and issubclass(annotation, Enum):
|
|
1677
|
+
return "choice", [member.value for member in annotation]
|
|
1678
|
+
if annotation is bool:
|
|
1679
|
+
return "bool", None
|
|
1680
|
+
if annotation is int:
|
|
1681
|
+
ranged = getattr(param, "min", None) is not None or (
|
|
1682
|
+
getattr(param, "max", None) is not None
|
|
1683
|
+
)
|
|
1684
|
+
return ("integer range" if ranged else "int"), None
|
|
1685
|
+
if annotation is float:
|
|
1686
|
+
return "float", None
|
|
1687
|
+
if isinstance(annotation, type) and issubclass(annotation, Path):
|
|
1688
|
+
info = getattr(descriptor, "parameter_info", None)
|
|
1689
|
+
files = getattr(info, "file_okay", True)
|
|
1690
|
+
return ("path" if files else "directory"), None
|
|
1691
|
+
return "str", None
|
|
1692
|
+
|
|
1693
|
+
|
|
1653
1694
|
def _param_entry(param: Any) -> dict[str, Any]:
|
|
1654
1695
|
"""One option or argument of a click command, for `dncli commands`.
|
|
1655
1696
|
Duck-typed: typer ships its own click, so isinstance checks miss."""
|
|
@@ -1660,15 +1701,9 @@ def _param_entry(param: Any) -> dict[str, Any]:
|
|
|
1660
1701
|
else:
|
|
1661
1702
|
longs = [opt for opt in param.opts if opt.startswith("--")]
|
|
1662
1703
|
name = longs[0] if longs else param.opts[0]
|
|
1663
|
-
choices =
|
|
1704
|
+
type_name, choices = _param_type(param)
|
|
1664
1705
|
if getattr(param, "is_flag", False):
|
|
1665
|
-
type_name = "flag"
|
|
1666
|
-
elif choices is not None:
|
|
1667
|
-
type_name = "choice"
|
|
1668
|
-
else:
|
|
1669
|
-
type_name = {"integer": "int", "text": "str"}.get(
|
|
1670
|
-
param.type.name, param.type.name
|
|
1671
|
-
)
|
|
1706
|
+
type_name, choices = "flag", None
|
|
1672
1707
|
entry: dict[str, Any] = {
|
|
1673
1708
|
"name": name,
|
|
1674
1709
|
"kind": kind,
|
|
@@ -3861,7 +3896,7 @@ def _wait_for_batch(
|
|
|
3861
3896
|
|
|
3862
3897
|
# --- BEGIN GENERATED COMMANDS (tools/generate.py; do not edit by hand) ---
|
|
3863
3898
|
|
|
3864
|
-
API_VERSION = "0.6.
|
|
3899
|
+
API_VERSION = "0.6.30"
|
|
3865
3900
|
SKILL_MD = """\
|
|
3866
3901
|
---
|
|
3867
3902
|
name: devnomads
|
|
@@ -11099,6 +11134,8 @@ def gen_services_sites_store(
|
|
|
11099
11134
|
"symfony",
|
|
11100
11135
|
"mediawiki",
|
|
11101
11136
|
"mediawiki_public",
|
|
11137
|
+
"joomla",
|
|
11138
|
+
"mmx_pagebuilder",
|
|
11102
11139
|
] = typer.Option(..., help="Web server preset for an application."),
|
|
11103
11140
|
mail_from: str | None = typer.Option(
|
|
11104
11141
|
None,
|
|
@@ -11233,6 +11270,8 @@ def gen_services_sites_update(
|
|
|
11233
11270
|
"symfony",
|
|
11234
11271
|
"mediawiki",
|
|
11235
11272
|
"mediawiki_public",
|
|
11273
|
+
"joomla",
|
|
11274
|
+
"mmx_pagebuilder",
|
|
11236
11275
|
]
|
|
11237
11276
|
| None
|
|
11238
11277
|
) = typer.Option(None, help="Web server preset for an application."),
|
|
@@ -469,6 +469,25 @@ def test_commands_catalog_describes_options():
|
|
|
469
469
|
assert "--out" not in names # global options are documented once
|
|
470
470
|
|
|
471
471
|
|
|
472
|
+
def test_commands_catalog_reads_click_types_too():
|
|
473
|
+
"""typer before 0.29 gives every parameter a click type instead of an
|
|
474
|
+
annotation; the catalog reads both."""
|
|
475
|
+
|
|
476
|
+
from types import SimpleNamespace as NS
|
|
477
|
+
|
|
478
|
+
choice = NS(type=NS(name="choice", choices=["a", "b"]))
|
|
479
|
+
integer = NS(type=NS(name="integer"))
|
|
480
|
+
assert dncli._param_type(choice) == ("choice", ["a", "b"])
|
|
481
|
+
assert dncli._param_type(integer) == ("int", None)
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
def test_commands_catalog_types_and_choices():
|
|
485
|
+
rows = {row["command"]: row for row in dncli.command_catalog()}
|
|
486
|
+
params = {p["name"]: p for p in rows["buckets update"]["params"]}
|
|
487
|
+
assert params["--policy"]["type"] == "choice"
|
|
488
|
+
assert params["--policy"]["choices"] == ["public", "private"]
|
|
489
|
+
|
|
490
|
+
|
|
472
491
|
def test_commands_catalog_covers_handwritten_commands():
|
|
473
492
|
result = runner.invoke(app, ["--out", "json", "commands", "dns", "records"])
|
|
474
493
|
rows = {row["command"]: row for row in json.loads(result.stdout)}
|
|
@@ -474,3 +474,18 @@ def test_current_list_gets_add_and_remove():
|
|
|
474
474
|
lines = generate.render_option(op.body[0])
|
|
475
475
|
assert any('"--add-alias"' in line for line in lines)
|
|
476
476
|
assert any('"--remove-alias"' in line for line in lines)
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
def test_add_choices_extends_the_spec_enum():
|
|
480
|
+
spec = body_spec(
|
|
481
|
+
"services.sites.store",
|
|
482
|
+
{"properties": {"profile": {"type": "string", "enum": ["default", "modx"]}}},
|
|
483
|
+
)
|
|
484
|
+
overlay = {
|
|
485
|
+
"services.sites.store": {
|
|
486
|
+
# modx is in the spec already: no duplicate once the spec catches up
|
|
487
|
+
"options": {"profile": {"add_choices": ["joomla", "modx"]}}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
(op,) = generate.parse_operations(spec, overlay)
|
|
491
|
+
assert op.body[0].choices == ["default", "modx", "joomla"]
|
|
@@ -340,7 +340,11 @@ def test_repeatable_list_option_with_singular_flag(configured):
|
|
|
340
340
|
def test_enum_option_rejects_unknown_value(configured):
|
|
341
341
|
result = runner.invoke(app, ["buckets", "update", "3", "--policy", "open"])
|
|
342
342
|
assert result.exit_code == 2
|
|
343
|
-
|
|
343
|
+
# typer wraps the message in a box; join its lines before matching
|
|
344
|
+
text = " ".join(
|
|
345
|
+
line.strip("│ ") for line in result.output.splitlines() if line.strip()
|
|
346
|
+
)
|
|
347
|
+
assert "'open' is not one of 'public', 'private'" in text
|
|
344
348
|
|
|
345
349
|
|
|
346
350
|
def job(status, job_id="j1", error=None):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|