feat(cli): add hyp CLI bundled with the SDK (#08ba2d)#33
Draft
KhaledSalhab-Develeap wants to merge 3 commits into
Draft
feat(cli): add hyp CLI bundled with the SDK (#08ba2d)#33KhaledSalhab-Develeap wants to merge 3 commits into
KhaledSalhab-Develeap wants to merge 3 commits into
Conversation
…08ba2d) Adds cli extra to project.optional-dependencies, pins typer[all]>=0.12,<1.0, adds hyp = "hyperping.cli._app:app" script entry, and includes typer in dev dependencies for testing.
…tenant subcommands (#08ba2d) Adds src/hyperping/cli/ subpackage with: - _config.py: API key resolution (flag > env var) - _output.py: rich table/panel formatters and JSON mode - _app.py: root hyp app with --api-key, --json, --version global options - _monitors.py: hyp monitor list/get/pause/resume - _incidents.py: hyp incident list/create/resolve - _statuspages.py: hyp statuspage show/subscribers - _tenant.py: hyp tenant onboard <name> [--monitor-url URL]... All commands reuse HyperpingClient. The --json flag works on all list/show commands for machine-readable output.
25 tests covering config resolution, monitor list/get/pause/resume, incident list/create/resolve, statuspage show/subscribers, and tenant onboard. Uses typer.testing.CliRunner with patched get_client; no real HTTP calls. Full suite at 95% coverage.
Collaborator
Author
|
CI matrix:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
hypCLI to the SDK, installable viapip install hyperping[cli]. The CLI is built with typer and covers monitors, incidents, status pages, and tenant onboarding. All commands reuse the existingHyperpingClient; no direct httpx usage appears in CLI code. A--jsonglobal flag makes every list/show command machine-readable for scripting and CI pipelines.What changed
pyproject.toml: newcliextra (typer[all]>=0.12,<1.0),hypscript entry point,Environment :: Consoleclassifier, typer added to dev deps.src/hyperping/cli/__init__.py: empty subpackage marker.src/hyperping/cli/_config.py:get_client(api_key)resolves key from flag orHYPERPING_API_KEYenv var; raisestyper.BadParameterif missing.src/hyperping/cli/_output.py:print_table,print_detail,print_success,print_error— rich table/panel in TTY mode, JSON via--json.src/hyperping/cli/_app.py: roothypapp with--api-key,--json,--versioncallback; registers all sub-apps.src/hyperping/cli/_monitors.py:hyp monitor list/get/pause/resume.src/hyperping/cli/_incidents.py:hyp incident list/create/resolve.src/hyperping/cli/_statuspages.py:hyp statuspage show/subscribers.src/hyperping/cli/_tenant.py:hyp tenant onboard <name> [--monitor-url URL]...(creates status page, optional monitors, wires them).tests/unit/test_cli_config.py: 4 tests for API key resolution.tests/unit/test_cli_monitors.py: 7 tests for monitor commands.tests/unit/test_cli_incidents.py: 7 tests for incident commands.tests/unit/test_cli_statuspages.py: 4 tests for statuspage commands.tests/unit/test_cli_tenant.py: 3 tests for tenant onboard.Design reasoning
Typer with
[all]extras bundles rich and shellingham, giving polished terminal output with zero extra dependency decisions. The sync client is used exclusively: CLI commands are one-shot and sequential, so there is no concurrency advantage toAsyncHyperpingClient. The CLI subpackage is isolated from the library's import path soimport hyperpingnever pulls in typer or rich.Verification matrix
uv run pytest tests/ -vuv run pytest tests/unit/test_cli_*.py -vuv run mypy src/hyperping/cli/ --strictuv run ruff check src/hyperping/cli/uv run hyp --versionhyp 1.7.0uv run hyp --helpuv run hyp monitor --helpAcceptance criteria
pip install hyperping[cli]installs typer and makeshypavailablehyp monitor listlists all monitors (table +--json)hyp monitor get <id>shows a single monitorhyp monitor pause <id>pauses a monitorhyp monitor resume <id>resumes a monitorhyp incident list [--status S]lists incidentshyp incident create --title T --text X --statuspage SPcreates an incidenthyp incident resolve <id> [--message M]resolves an incidenthyp statuspage show <id>shows a status pagehyp statuspage subscribers <id>lists subscribershyp tenant onboard <name> [--monitor-url URL]...creates page + monitorsHyperpingClient(no direct httpx usage in CLI)--jsonglobal flag works on all list/show commandsFollow-up items
tenant onboardis implemented as "create status page + optional monitors". If a projects API endpoint is added, a dedicated follow-up ticket should extend this command.