dhis2w-cli 0.6.0__tar.gz → 0.10.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,82 @@
1
+ Metadata-Version: 2.3
2
+ Name: dhis2w-cli
3
+ Version: 0.10.0
4
+ Summary: dhis2 command-line interface (Typer) — mounts plugins from dhis2w-core.
5
+ Author: Morten Hansen
6
+ Author-email: Morten Hansen <morten@winterop.com>
7
+ Requires-Dist: dhis2w-core>=0.10.0,<0.11
8
+ Requires-Dist: typer>=0.24
9
+ Requires-Dist: rich>=15
10
+ Requires-Dist: dhis2w-browser>=0.10.0,<0.11 ; extra == 'browser'
11
+ Requires-Python: >=3.13
12
+ Provides-Extra: browser
13
+ Description-Content-Type: text/markdown
14
+
15
+ # dhis2w-cli
16
+
17
+ Typer console script `dhis2` for working with DHIS2 instances from the shell. Discovers plugins from `dhis2w-core` — sixteen top-level domains covering metadata, data, analytics, tracker, users, routes, files, messaging, apps, doctor, and developer tools.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ # Drops `dhis2` on $PATH
23
+ uv tool install dhis2w-cli
24
+
25
+ # With Playwright UI automation (browser screenshots, OIDC login, PAT minting)
26
+ uv tool install 'dhis2w-cli[browser]'
27
+ playwright install chromium # one-time, after the install above
28
+
29
+ # Update later
30
+ uv tool upgrade dhis2w-cli
31
+ ```
32
+
33
+ Or run on demand without installing:
34
+
35
+ ```bash
36
+ uvx --from dhis2w-cli dhis2 --help
37
+ ```
38
+
39
+ ## Configure
40
+
41
+ The CLI reads a profile from `.dhis2/profiles.toml` (project) or `~/.config/dhis2/profiles.toml` (user). One-shot bootstrap:
42
+
43
+ ```bash
44
+ dhis2 profile bootstrap mywork
45
+ ```
46
+
47
+ Or set env vars and skip the profile system entirely:
48
+
49
+ ```bash
50
+ export DHIS2_URL=https://dhis2.example.org
51
+ export DHIS2_PAT=d2p_...
52
+ dhis2 system info
53
+ ```
54
+
55
+ ## Surface
56
+
57
+ ```
58
+ dhis2 analytics DHIS2 analytics queries.
59
+ dhis2 apps DHIS2 apps — /api/apps + /api/appHub.
60
+ dhis2 browser Playwright UI automation (only with [browser] extra).
61
+ dhis2 data DHIS2 data values (aggregate + tracker).
62
+ dhis2 dev Developer/operator tools.
63
+ dhis2 doctor Probe a DHIS2 instance for known gotchas + requirements.
64
+ dhis2 files Manage DHIS2 documents + file resources.
65
+ dhis2 maintenance DHIS2 maintenance (tasks, cache, integrity, cleanup, refresh).
66
+ dhis2 messaging DHIS2 internal messaging.
67
+ dhis2 metadata DHIS2 metadata inspection.
68
+ dhis2 profile Manage DHIS2 profiles.
69
+ dhis2 route DHIS2 integration routes.
70
+ dhis2 system DHIS2 system info.
71
+ dhis2 user DHIS2 user administration.
72
+ dhis2 user-group DHIS2 user-group administration.
73
+ dhis2 user-role DHIS2 user-role administration.
74
+ ```
75
+
76
+ `dhis2 --help` for the full tree; `dhis2 <group> --help` for each.
77
+
78
+ ## Documentation
79
+
80
+ Full CLI reference: https://winterop-com.github.io/dhis2w-utils/cli-reference/.
81
+
82
+ `dhis2w-cli` is one member of the [`dhis2w-utils`](https://github.com/winterop-com/dhis2w-utils) workspace. The MCP server (`dhis2w-mcp`) exposes the same plugin surface as MCP tools.
@@ -0,0 +1,68 @@
1
+ # dhis2w-cli
2
+
3
+ Typer console script `dhis2` for working with DHIS2 instances from the shell. Discovers plugins from `dhis2w-core` — sixteen top-level domains covering metadata, data, analytics, tracker, users, routes, files, messaging, apps, doctor, and developer tools.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ # Drops `dhis2` on $PATH
9
+ uv tool install dhis2w-cli
10
+
11
+ # With Playwright UI automation (browser screenshots, OIDC login, PAT minting)
12
+ uv tool install 'dhis2w-cli[browser]'
13
+ playwright install chromium # one-time, after the install above
14
+
15
+ # Update later
16
+ uv tool upgrade dhis2w-cli
17
+ ```
18
+
19
+ Or run on demand without installing:
20
+
21
+ ```bash
22
+ uvx --from dhis2w-cli dhis2 --help
23
+ ```
24
+
25
+ ## Configure
26
+
27
+ The CLI reads a profile from `.dhis2/profiles.toml` (project) or `~/.config/dhis2/profiles.toml` (user). One-shot bootstrap:
28
+
29
+ ```bash
30
+ dhis2 profile bootstrap mywork
31
+ ```
32
+
33
+ Or set env vars and skip the profile system entirely:
34
+
35
+ ```bash
36
+ export DHIS2_URL=https://dhis2.example.org
37
+ export DHIS2_PAT=d2p_...
38
+ dhis2 system info
39
+ ```
40
+
41
+ ## Surface
42
+
43
+ ```
44
+ dhis2 analytics DHIS2 analytics queries.
45
+ dhis2 apps DHIS2 apps — /api/apps + /api/appHub.
46
+ dhis2 browser Playwright UI automation (only with [browser] extra).
47
+ dhis2 data DHIS2 data values (aggregate + tracker).
48
+ dhis2 dev Developer/operator tools.
49
+ dhis2 doctor Probe a DHIS2 instance for known gotchas + requirements.
50
+ dhis2 files Manage DHIS2 documents + file resources.
51
+ dhis2 maintenance DHIS2 maintenance (tasks, cache, integrity, cleanup, refresh).
52
+ dhis2 messaging DHIS2 internal messaging.
53
+ dhis2 metadata DHIS2 metadata inspection.
54
+ dhis2 profile Manage DHIS2 profiles.
55
+ dhis2 route DHIS2 integration routes.
56
+ dhis2 system DHIS2 system info.
57
+ dhis2 user DHIS2 user administration.
58
+ dhis2 user-group DHIS2 user-group administration.
59
+ dhis2 user-role DHIS2 user-role administration.
60
+ ```
61
+
62
+ `dhis2 --help` for the full tree; `dhis2 <group> --help` for each.
63
+
64
+ ## Documentation
65
+
66
+ Full CLI reference: https://winterop-com.github.io/dhis2w-utils/cli-reference/.
67
+
68
+ `dhis2w-cli` is one member of the [`dhis2w-utils`](https://github.com/winterop-com/dhis2w-utils) workspace. The MCP server (`dhis2w-mcp`) exposes the same plugin surface as MCP tools.
@@ -1,18 +1,18 @@
1
1
  [project]
2
2
  name = "dhis2w-cli"
3
- version = "0.6.0"
3
+ version = "0.10.0"
4
4
  description = "dhis2 command-line interface (Typer) — mounts plugins from dhis2w-core."
5
5
  readme = "README.md"
6
6
  authors = [{ name = "Morten Hansen", email = "morten@winterop.com" }]
7
7
  requires-python = ">=3.13"
8
8
  dependencies = [
9
- "dhis2w-core>=0.6.0,<0.7",
9
+ "dhis2w-core>=0.10.0,<0.11",
10
10
  "typer>=0.24",
11
11
  "rich>=15",
12
12
  ]
13
13
 
14
14
  [project.optional-dependencies]
15
- browser = ["dhis2w-browser>=0.6.0,<0.7"]
15
+ browser = ["dhis2w-browser>=0.10.0,<0.11"]
16
16
 
17
17
  [project.scripts]
18
18
  dhis2 = "dhis2w_cli.main:main"
@@ -4,16 +4,52 @@ from __future__ import annotations
4
4
 
5
5
  import logging
6
6
  import os
7
+ from importlib.metadata import PackageNotFoundError, version
7
8
  from typing import Annotated
8
9
 
9
10
  import typer
10
11
  from dhis2w_core.cli_errors import run_app
11
12
  from dhis2w_core.cli_output import JSON_OUTPUT
12
- from dhis2w_core.plugin import discover_plugins
13
+ from dhis2w_core.plugin import DEFAULT_VERSION_KEY, discover_plugins, resolve_startup_version
13
14
  from dhis2w_core.rich_console import STDERR_CONSOLE
14
15
  from rich.logging import RichHandler
15
16
 
16
17
 
18
+ def _version_banner() -> str:
19
+ """Multi-line banner shown for `dhis2 --version` — package version + active plugin tree.
20
+
21
+ Surfaces which plugin tree (`v41` / `v42` / `v43`) the CLI booted with
22
+ and where that came from in the resolution chain (`profile.version` →
23
+ `DHIS2_VERSION` env → default). Helps debug "which DHIS2 major is
24
+ this CLI talking to" without reading the profile by hand.
25
+ """
26
+ try:
27
+ pkg_version = version("dhis2w-cli")
28
+ except PackageNotFoundError:
29
+ pkg_version = "unknown"
30
+ active = resolve_startup_version()
31
+ env_version = os.environ.get("DHIS2_VERSION", "").strip()
32
+ if (
33
+ env_version in {"41", "42", "43"}
34
+ and f"v{env_version}" == active
35
+ or env_version in {"v41", "v42", "v43"}
36
+ and env_version == active
37
+ ):
38
+ source = f"DHIS2_VERSION={env_version!r} env"
39
+ elif active == DEFAULT_VERSION_KEY:
40
+ source = "default (no profile.version, no DHIS2_VERSION env)"
41
+ else:
42
+ source = "profile.version"
43
+ return f"dhis2 {pkg_version} (plugin tree: {active} — {source})"
44
+
45
+
46
+ def _version_callback(value: bool) -> None:
47
+ """Eager `--version` callback — print the banner and exit."""
48
+ if value:
49
+ typer.echo(_version_banner())
50
+ raise typer.Exit(0)
51
+
52
+
17
53
  def _enable_debug_logging() -> None:
18
54
  """Turn on dhis2w-client HTTP traces + dhis2w-core debug logs on stderr.
19
55
 
@@ -78,6 +114,16 @@ def build_app() -> typer.Typer:
78
114
  help="Emit raw JSON to stdout instead of Rich tables (uniform across all commands).",
79
115
  ),
80
116
  ] = False,
117
+ _version: Annotated[
118
+ bool,
119
+ typer.Option(
120
+ "--version",
121
+ "-V",
122
+ help="Print the CLI version + active plugin tree and exit.",
123
+ callback=_version_callback,
124
+ is_eager=True,
125
+ ),
126
+ ] = False,
81
127
  ) -> None:
82
128
  """Set the active DHIS2 profile + optional debug logging + output mode for this invocation."""
83
129
  if profile:
@@ -89,7 +135,7 @@ def build_app() -> typer.Typer:
89
135
  # invocation must not leak into the next one.
90
136
  JSON_OUTPUT.set(json_)
91
137
 
92
- for plugin in discover_plugins():
138
+ for plugin in discover_plugins(resolve_startup_version()):
93
139
  plugin.register_cli(app)
94
140
  return app
95
141
 
dhis2w_cli-0.6.0/PKG-INFO DELETED
@@ -1,14 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: dhis2w-cli
3
- Version: 0.6.0
4
- Summary: dhis2 command-line interface (Typer) — mounts plugins from dhis2w-core.
5
- Author: Morten Hansen
6
- Author-email: Morten Hansen <morten@winterop.com>
7
- Requires-Dist: dhis2w-core>=0.6.0,<0.7
8
- Requires-Dist: typer>=0.24
9
- Requires-Dist: rich>=15
10
- Requires-Dist: dhis2w-browser>=0.6.0,<0.7 ; extra == 'browser'
11
- Requires-Python: >=3.13
12
- Provides-Extra: browser
13
- Description-Content-Type: text/markdown
14
-
File without changes