Skip to content

Commit 1d7e04b

Browse files
committed
Separate CLI creation from __init__ files
1 parent 33715cf commit 1d7e04b

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
- Restructure the CLI for avoiding the import race condition
1111
- Make the commands easier to rebrand
1212
- Add return value to `ConvertData.check_datasets`
13+
- Fix geopandas `datetime64` conversion issue
14+
- `CollectionSchemas`: Make some methods reusable
15+
- Separate CLI creation from `__init__.py` files
1316

1417
## [v0.2.1] - 2025-08-25
1518

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dependencies = [
4343
]
4444

4545
[project.scripts]
46-
vec = "vecorel_cli:vecorel_cli"
46+
vec = "vecorel_cli.cli.setup:run"
4747

4848
[project.urls]
4949
"Homepage" = "https://github.com/vecorel/cli"

vecorel_cli/__init__.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +0,0 @@
1-
from .registry import Registry
2-
3-
if __name__ == Registry.src_package or __name__ == "__main__":
4-
import click
5-
6-
@click.group()
7-
@click.version_option(version=Registry.get_version(), prog_name=Registry.cli_title)
8-
def vecorel_cli():
9-
commands = Registry.get_commands()
10-
for command in commands:
11-
click_cmd = command.get_cli_command(command)
12-
click_args = command.get_cli_args().values()
13-
for arg in click_args:
14-
click_cmd = arg(click_cmd)
15-
vecorel_cli.add_command(click_cmd)

vecorel_cli/cli/setup.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def setup_cli():
2+
import click
3+
4+
from ..registry import Registry
5+
6+
@click.group()
7+
@click.version_option(version=Registry.get_version(), prog_name=Registry.cli_title)
8+
def cli():
9+
pass
10+
11+
commands = Registry.get_commands()
12+
for command in commands:
13+
click_cmd = command.get_cli_command(command)
14+
click_args = command.get_cli_args().values()
15+
for arg in click_args:
16+
click_cmd = arg(click_cmd)
17+
cli.add_command(click_cmd)
18+
19+
return cli()
20+
21+
22+
run = setup_cli()

0 commit comments

Comments
 (0)