From be0c8dd0cda092575255cd35d6bc2c1893e9afc6 Mon Sep 17 00:00:00 2001 From: Mel Cadano Date: Mon, 2 Mar 2026 19:40:05 +0800 Subject: [PATCH 1/2] feat(cli): add `info` command --- src/ciopen/__init__.py | 4 +++- src/ciopen/cli.py | 2 ++ src/ciopen/commands/info.py | 10 ++++++++++ tests/integration/test_print.py | 21 +++++++++++++++++++++ tests/integration/test_version_print.py | 11 ----------- tests/unit/commands/test_info.py | 18 ++++++++++++++++++ tests/unit/test_cli.py | 1 + 7 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 src/ciopen/commands/info.py create mode 100644 tests/integration/test_print.py delete mode 100644 tests/integration/test_version_print.py create mode 100644 tests/unit/commands/test_info.py diff --git a/src/ciopen/__init__.py b/src/ciopen/__init__.py index 4772c64..c28dce9 100644 --- a/src/ciopen/__init__.py +++ b/src/ciopen/__init__.py @@ -1,3 +1,5 @@ -from importlib.metadata import version +from importlib.metadata import metadata, version __version__ = version("ciopen") + +__author__ = metadata("ciopen")["Author-email"] diff --git a/src/ciopen/cli.py b/src/ciopen/cli.py index 5f2203a..63acf99 100644 --- a/src/ciopen/cli.py +++ b/src/ciopen/cli.py @@ -1,6 +1,7 @@ import typer from ciopen.commands.doctor import doctor_command +from ciopen.commands.info import info_command from ciopen.commands.open import open_command from ciopen.commands.pr import pr_command from ciopen.commands.provider import provider_command @@ -12,6 +13,7 @@ app.callback(invoke_without_command=True)(open_command) app.command(name="version", help="Show ciopen version")(version_command) +app.command(name="info", help="Show ciopen information")(info_command) app.command(name="doctor", help="Check if everything is set up right")(doctor_command) app.command(name="provider", help="Show which CI provider is detected")(provider_command) app.command(name="repo", help="Open the main page of this repository")(repo_command) diff --git a/src/ciopen/commands/info.py b/src/ciopen/commands/info.py new file mode 100644 index 0000000..6503339 --- /dev/null +++ b/src/ciopen/commands/info.py @@ -0,0 +1,10 @@ +import typer + +from ciopen import __author__, __version__ + + +def info_command() -> None: + typer.echo(f"ciopen {__version__}") + typer.echo(f"Author: {__author__}") + # Make this not hard coded in the future + typer.echo("Homepage: https://github.com/mel-cdn/ciopen") diff --git a/tests/integration/test_print.py b/tests/integration/test_print.py new file mode 100644 index 0000000..b9ff31a --- /dev/null +++ b/tests/integration/test_print.py @@ -0,0 +1,21 @@ +from contextlib import chdir + +from ciopen import __author__, __version__, cli + + +def test_version_command_should_print_current_version(fx_git_repo, fx_cli_runner): + with chdir(fx_git_repo): + result = fx_cli_runner.invoke(cli.app, ["version"]) + + assert result.exit_code == 0 + assert f"ciopen {__version__}" in result.output + + +def test_info_command_should_print_information(fx_git_repo, fx_cli_runner): + with chdir(fx_git_repo): + result = fx_cli_runner.invoke(cli.app, ["info"]) + + assert result.exit_code == 0 + assert f"ciopen {__version__}" in result.output + assert f"Author: {__author__}" in result.output + assert f"Homepage: https://github.com/mel-cdn/ciopen" in result.output diff --git a/tests/integration/test_version_print.py b/tests/integration/test_version_print.py deleted file mode 100644 index e62d1ff..0000000 --- a/tests/integration/test_version_print.py +++ /dev/null @@ -1,11 +0,0 @@ -from contextlib import chdir - -from ciopen import __version__, cli - - -def test_version_command_should_print_current_version(fx_git_repo, fx_cli_runner): - with chdir(fx_git_repo): - result = fx_cli_runner.invoke(cli.app, ["version"]) - - assert result.exit_code == 0 - assert f"ciopen {__version__}" in result.output diff --git a/tests/unit/commands/test_info.py b/tests/unit/commands/test_info.py new file mode 100644 index 0000000..f330abc --- /dev/null +++ b/tests/unit/commands/test_info.py @@ -0,0 +1,18 @@ +from unittest.mock import call, patch + +from ciopen.commands.info import info_command + + +@patch(f"{info_command.__module__}.typer.echo", spec=True) +@patch(f"{info_command.__module__}.__author__", spec=True) +@patch(f"{info_command.__module__}.__version__", spec=True) +def test_info_command_should_show_version(m_version, m_author, m_echo): + m_version.__str__.return_value = "1.2.3" + m_author.__str__.return_value = "Name of Author" + + assert info_command() is None + assert m_echo.mock_calls == [ + call("ciopen 1.2.3"), + call("Author: Name of Author"), + call("Homepage: https://github.com/mel-cdn/ciopen"), + ] diff --git a/tests/unit/test_cli.py b/tests/unit/test_cli.py index 3588938..09a50fa 100644 --- a/tests/unit/test_cli.py +++ b/tests/unit/test_cli.py @@ -10,6 +10,7 @@ def test_cli_help_lists_commands(): # Ensure commands are registered (don’t overfit exact help formatting) assert "version" in result.stdout + assert "info" in result.stdout assert "doctor" in result.stdout assert "provider" in result.stdout assert "repo" in result.stdout From 7c97f817375cb1da19fed7da14969805b202e7a5 Mon Sep 17 00:00:00 2001 From: Mel Cadano Date: Mon, 2 Mar 2026 19:40:35 +0800 Subject: [PATCH 2/2] docs: update PyPi and GitHub docs --- README.md | 19 ++++++++++--------- pyproject.toml | 48 +++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 669ea10..a4606ff 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Check out the docs: Open CI pipeline on your default browser: ```bash -ciopen +$ ciopen ``` --- @@ -37,16 +37,16 @@ ciopen ### Using `pip` ```bash -pip install ciopen +$ pip install ciopen ``` ### Using pip (editable / dev mode) ```bash -git clone https://github.com/mel-cdn/ciopen.git -cd ciopen -pipenv shell # or activate your virtualenv -./run-checks.sh # Install all dependencies +$ git clone https://github.com/mel-cdn/ciopen.git +$ cd ciopen +$ pipenv shell # or activate your virtualenv +$ ./run-checks.sh # Install all dependencies ``` --- @@ -56,7 +56,7 @@ pipenv shell # or activate your virtualenv Show helpful CLI documentation: ```bash -ciopen --help +$ ciopen --help Usage: ciopen [OPTIONS] COMMAND [ARGS]... @@ -69,6 +69,7 @@ ciopen --help ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─ Commands ────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ version Show ciopen version │ + │ info Show ciopen information │ │ doctor Check if everything is set up right │ │ provider Show which CI provider is detected │ │ repo Open the main page of this repository │ @@ -79,7 +80,7 @@ ciopen --help Open your repository's main page: ```bash -ciopen repo +$ ciopen repo Opening https://github.com/mel-cdn/ciopen ``` @@ -87,7 +88,7 @@ ciopen repo Check if it's going to work with diagnostics: ```bash -ciopen doctor +$ ciopen doctor ciopen 0.0.5 Running diagnostics... diff --git a/pyproject.toml b/pyproject.toml index 8e4f0c3..b365493 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,13 @@ +# ----------------------------- # Build system +# ----------------------------- [build-system] -requires = ["setuptools>=61"] +requires = ["setuptools>=69"] build-backend = "setuptools.build_meta" -# Project metadata +# ----------------------------- +# Project metadata (PyPI) +# ----------------------------- [project] name = "ciopen" version = "0.0.8" @@ -12,19 +16,44 @@ readme = { file = "README.md", content-type = "text/markdown" } license = "MIT" license-files = ["LICENSE"] authors = [ - { name = "Mel Cadano", email = "mel.cdn@outlook.ph" }, + { name = "Mel Cadano", email = "mel.cdn@outlook.ph" } ] - requires-python = ">=3.11" + +keywords = ["cli", "ci", "github-actions", "devtools", "automation"] + + +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Environment :: Console", + "Topic :: Software Development :: Build Tools", +] dependencies = [ - "typer>=0.24.1" + "typer>=0.12" ] -# CLI entry points +# ----------------------------- +# CLI entry point +# ----------------------------- [project.scripts] ciopen = "ciopen.cli:app" -# Dev dependencies +# ----------------------------- +# Project links (shown on PyPI) +# ----------------------------- +[project.urls] +Homepage = "https://github.com/mel-cdn/ciopen" +Repository = "https://github.com/mel-cdn/ciopen" +Issues = "https://github.com/mel-cdn/ciopen/issues" +Changelog = "https://github.com/mel-cdn/ciopen/blob/main/CHANGELOG.md" + +# ----------------------------- +# Optional Dev dependencies +# ----------------------------- [project.optional-dependencies] dev = [ "pytest==9.0.2", @@ -33,7 +62,9 @@ dev = [ "conventional-pre-commit==4.4.0", ] -# Semantic versioning +# ----------------------------- +# Semantic Release Configuration +# ----------------------------- [tool.semantic_release] branch = "main" version_source = "tag" @@ -48,7 +79,6 @@ version_toml = [ "pyproject.toml:project.version", ] -# Optional: override commit parsing [tool.semantic_release.commit_parser_options] patch_tags = ["fix", "chore", "docs", "style", "refactor", "test"] minor_tags = ["feat"]