click-cadquery 0.1.0__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.
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.3
2
+ Name: click-cadquery
3
+ Version: 0.1.0
4
+ Summary: Add your description here
5
+ Requires-Dist: click>=8.2.1
6
+ Requires-Dist: pydantic>=2.11.7
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+
File without changes
@@ -0,0 +1,14 @@
1
+ [project]
2
+ name = "click-cadquery"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ dependencies = [
8
+ "click>=8.2.1",
9
+ "pydantic>=2.11.7",
10
+ ]
11
+
12
+ [build-system]
13
+ requires = ["uv_build>=0.8.3,<0.9.0"]
14
+ build-backend = "uv_build"
@@ -0,0 +1,47 @@
1
+ from collections.abc import Callable
2
+ from pathlib import Path
3
+ from typing import Any, TypeVar
4
+
5
+ import click
6
+ from pydantic import BaseModel
7
+
8
+ TypePath = click.types.Path(path_type=Path)
9
+ T = TypeVar("T", bound=BaseModel)
10
+
11
+ # (param, output, show)
12
+ CommandFunction = Callable[[T, Path | None, bool], None]
13
+
14
+
15
+ def define_options(klass: type[BaseModel]): # type: ignore
16
+ """
17
+ Decorator to build a command function with click.option
18
+ """
19
+
20
+ def decorator(fn: CommandFunction): # type: ignore
21
+ def decorated(output: Path | None, show: bool, **kwargs: Any) -> None:
22
+ return fn(param=klass(**kwargs), output=output, show=show) # type: ignore
23
+
24
+ decorated = click.argument("output", type=TypePath, required=False)(decorated)
25
+ decorated = click.option(
26
+ "--show", is_flag=True, help="Show the result in a viewer"
27
+ )(decorated)
28
+
29
+ for field_name, field_data in klass.model_fields.items():
30
+ anot = field_data.annotation
31
+ assert isinstance(anot, type)
32
+
33
+ # e.g. @click.option("--width", type=float, default=100.0)
34
+ decorated = click.option(
35
+ _to_option_name(field_name),
36
+ type=anot,
37
+ default=field_data.default,
38
+ help=field_data.description,
39
+ )(decorated)
40
+
41
+ return decorated
42
+
43
+ return decorator
44
+
45
+
46
+ def _to_option_name(field_name: str) -> str:
47
+ return f"--{field_name.replace('_', '-')}"
@@ -0,0 +1,13 @@
1
+ import subprocess
2
+
3
+
4
+ def version_number() -> int:
5
+ result = subprocess.run(
6
+ ["git", "log", "--oneline"],
7
+ capture_output=True,
8
+ text=True,
9
+ )
10
+ if result.returncode == 0:
11
+ return len([line for line in result.stdout.split("\n") if line.strip() != ""])
12
+ else:
13
+ return 0
File without changes