datacommons-cli 0.0.1__tar.gz → 0.0.3__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.
- {datacommons_cli-0.0.1 → datacommons_cli-0.0.3}/PKG-INFO +1 -1
- datacommons_cli-0.0.1/datacommons_cli/version.py → datacommons_cli-0.0.3/datacommons_cli/__init__.py +1 -1
- datacommons_cli-0.0.3/datacommons_cli/cli.py +74 -0
- {datacommons_cli-0.0.1 → datacommons_cli-0.0.3}/datacommons_cli.egg-info/PKG-INFO +1 -1
- {datacommons_cli-0.0.1 → datacommons_cli-0.0.3}/datacommons_cli.egg-info/SOURCES.txt +3 -2
- {datacommons_cli-0.0.1 → datacommons_cli-0.0.3}/datacommons_cli.egg-info/entry_points.txt +1 -0
- {datacommons_cli-0.0.1 → datacommons_cli-0.0.3}/pyproject.toml +2 -1
- datacommons_cli-0.0.1/datacommons_cli/cli.py → datacommons_cli-0.0.3/tests/test_cli.py +13 -10
- {datacommons_cli-0.0.1 → datacommons_cli-0.0.3}/datacommons_cli.egg-info/dependency_links.txt +0 -0
- {datacommons_cli-0.0.1 → datacommons_cli-0.0.3}/datacommons_cli.egg-info/requires.txt +0 -0
- {datacommons_cli-0.0.1 → datacommons_cli-0.0.3}/datacommons_cli.egg-info/top_level.txt +0 -0
- {datacommons_cli-0.0.1 → datacommons_cli-0.0.3}/setup.cfg +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Copyright 2025 Google LLC.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
import os
|
|
16
|
+
|
|
17
|
+
import click
|
|
18
|
+
|
|
19
|
+
from datacommons_admin.admin_cli import admin as admin_cli
|
|
20
|
+
|
|
21
|
+
from . import __version__
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def get_logo_color():
|
|
25
|
+
"""Determine the best logo color based on terminal capabilities"""
|
|
26
|
+
colorterm = os.environ.get("COLORTERM", "").lower()
|
|
27
|
+
if colorterm in ("truecolor", "24bit"):
|
|
28
|
+
return (7, 81, 179)
|
|
29
|
+
|
|
30
|
+
term = os.environ.get("TERM", "").lower()
|
|
31
|
+
if "256color" in term or colorterm:
|
|
32
|
+
return 26 # Royal blue color index in 256-color palette
|
|
33
|
+
|
|
34
|
+
return "blue"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class CustomGroup(click.Group):
|
|
38
|
+
"""Custom click.Group to preserve logo formatting and newlines in help text"""
|
|
39
|
+
|
|
40
|
+
def format_help_text(self, ctx, formatter):
|
|
41
|
+
if self.help:
|
|
42
|
+
formatter.write_paragraph()
|
|
43
|
+
with formatter.indentation():
|
|
44
|
+
for line in self.help.splitlines():
|
|
45
|
+
if line:
|
|
46
|
+
formatter.write(f"{' ' * formatter.current_indent}{line}\n")
|
|
47
|
+
else:
|
|
48
|
+
formatter.write("\n")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def cli_help() -> str:
|
|
52
|
+
"""Return help string for the CLI"""
|
|
53
|
+
logo = (
|
|
54
|
+
" ██████╗ ██████╗\n"
|
|
55
|
+
" ██╔══██╗ ██╔════╝\n"
|
|
56
|
+
" ██║ ██║ ██║ \n"
|
|
57
|
+
" ██║ ██║ ██║ \n"
|
|
58
|
+
" ██████╔╝ ╚██████╗\n"
|
|
59
|
+
" ╚═════╝ ╚═════╝"
|
|
60
|
+
)
|
|
61
|
+
styled_logo = click.style(logo, fg=get_logo_color(), bold=True)
|
|
62
|
+
version_str = click.style(f"v{__version__}", fg="bright_black")
|
|
63
|
+
return f"{styled_logo}\n\nData Commons CLI {version_str}"
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@click.group(cls=CustomGroup, help=cli_help())
|
|
67
|
+
@click.version_option(version=__version__, prog_name="Data Commons CLI")
|
|
68
|
+
def cli():
|
|
69
|
+
"""Data Commons CLI"""
|
|
70
|
+
pass
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# Add admin CLI commands to the main CLI
|
|
74
|
+
cli.add_command(admin_cli)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
pyproject.toml
|
|
2
|
+
datacommons_cli/__init__.py
|
|
2
3
|
datacommons_cli/cli.py
|
|
3
|
-
datacommons_cli/version.py
|
|
4
4
|
datacommons_cli.egg-info/PKG-INFO
|
|
5
5
|
datacommons_cli.egg-info/SOURCES.txt
|
|
6
6
|
datacommons_cli.egg-info/dependency_links.txt
|
|
7
7
|
datacommons_cli.egg-info/entry_points.txt
|
|
8
8
|
datacommons_cli.egg-info/requires.txt
|
|
9
|
-
datacommons_cli.egg-info/top_level.txt
|
|
9
|
+
datacommons_cli.egg-info/top_level.txt
|
|
10
|
+
tests/test_cli.py
|
|
@@ -16,6 +16,7 @@ urls = {Homepage = "https://github.com/datacommonsorg/datacommons"}
|
|
|
16
16
|
|
|
17
17
|
[project.scripts]
|
|
18
18
|
datacommons = "datacommons_cli.cli:cli"
|
|
19
|
+
datacommons-cli = "datacommons_cli.cli:cli"
|
|
19
20
|
|
|
20
21
|
[build-system]
|
|
21
22
|
requires = ["uv", "setuptools"]
|
|
@@ -25,4 +26,4 @@ build-backend = "setuptools.build_meta"
|
|
|
25
26
|
include-package-data = true
|
|
26
27
|
|
|
27
28
|
[tool.setuptools.dynamic]
|
|
28
|
-
version = {attr = "datacommons_cli.
|
|
29
|
+
version = {attr = "datacommons_cli.__version__"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright
|
|
1
|
+
# Copyright 2026 Google LLC.
|
|
2
2
|
#
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
# you may not use this file except in compliance with the License.
|
|
@@ -12,16 +12,19 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
import
|
|
15
|
+
from click.testing import CliRunner
|
|
16
|
+
from datacommons_cli.cli import cli, __version__
|
|
16
17
|
|
|
17
|
-
from datacommons_admin.admin_cli import admin as admin_cli
|
|
18
18
|
|
|
19
|
+
def test_cli_version() -> None:
|
|
20
|
+
runner = CliRunner()
|
|
21
|
+
result = runner.invoke(cli, ["--version"])
|
|
22
|
+
assert result.exit_code == 0
|
|
23
|
+
assert f"Data Commons CLI, version {__version__}" in result.output
|
|
19
24
|
|
|
20
|
-
@click.group()
|
|
21
|
-
def cli():
|
|
22
|
-
"""Datacommons CLI suite"""
|
|
23
|
-
pass
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
def test_cli_help() -> None:
|
|
27
|
+
runner = CliRunner()
|
|
28
|
+
result = runner.invoke(cli, ["--help"])
|
|
29
|
+
assert result.exit_code == 0
|
|
30
|
+
assert "Data Commons CLI" in result.output
|
{datacommons_cli-0.0.1 → datacommons_cli-0.0.3}/datacommons_cli.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|