Skip to content

feat(cli): add hyp CLI bundled with the SDK (#08ba2d)#33

Draft
KhaledSalhab-Develeap wants to merge 3 commits into
mainfrom
feat/08ba2d-hyp-cli
Draft

feat(cli): add hyp CLI bundled with the SDK (#08ba2d)#33
KhaledSalhab-Develeap wants to merge 3 commits into
mainfrom
feat/08ba2d-hyp-cli

Conversation

@KhaledSalhab-Develeap

Copy link
Copy Markdown
Collaborator

Summary

Adds a hyp CLI to the SDK, installable via pip install hyperping[cli]. The CLI is built with typer and covers monitors, incidents, status pages, and tenant onboarding. All commands reuse the existing HyperpingClient; no direct httpx usage appears in CLI code. A --json global flag makes every list/show command machine-readable for scripting and CI pipelines.

What changed

  • pyproject.toml: new cli extra (typer[all]>=0.12,<1.0), hyp script entry point, Environment :: Console classifier, 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 or HYPERPING_API_KEY env var; raises typer.BadParameter if 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: root hyp app with --api-key, --json, --version callback; 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 to AsyncHyperpingClient. The CLI subpackage is isolated from the library's import path so import hyperping never pulls in typer or rich.

Verification matrix

Check Result
uv run pytest tests/ -v 588 passed, 95.25% coverage
uv run pytest tests/unit/test_cli_*.py -v 25 passed
uv run mypy src/hyperping/cli/ --strict No issues
uv run ruff check src/hyperping/cli/ All checks passed
uv run hyp --version hyp 1.7.0
uv run hyp --help Renders correctly
uv run hyp monitor --help Renders correctly

Acceptance criteria

  • pip install hyperping[cli] installs typer and makes hyp available
  • hyp monitor list lists all monitors (table + --json)
  • hyp monitor get <id> shows a single monitor
  • hyp monitor pause <id> pauses a monitor
  • hyp monitor resume <id> resumes a monitor
  • hyp incident list [--status S] lists incidents
  • hyp incident create --title T --text X --statuspage SP creates an incident
  • hyp incident resolve <id> [--message M] resolves an incident
  • hyp statuspage show <id> shows a status page
  • hyp statuspage subscribers <id> lists subscribers
  • hyp tenant onboard <name> [--monitor-url URL]... creates page + monitors
  • All subcommands reuse HyperpingClient (no direct httpx usage in CLI)
  • --json global flag works on all list/show commands
  • Existing tests still pass (no regressions)

Follow-up items

  • The Hyperping API exposes no project/tenant CRUD endpoints, so tenant onboard is implemented as "create status page + optional monitors". If a projects API endpoint is added, a dedicated follow-up ticket should extend this command.

…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.
@KhaledSalhab-Develeap

Copy link
Copy Markdown
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant