Skip to content

feat: artisan commands — listen, post, health#34

Merged
jordanpartridge merged 2 commits into
mainfrom
feat/10-artisan-commands
Apr 27, 2026
Merged

feat: artisan commands — listen, post, health#34
jordanpartridge merged 2 commits into
mainfrom
feat/10-artisan-commands

Conversation

@jordanpartridge
Copy link
Copy Markdown
Contributor

Summary

Closes #10

Three artisan commands for the package:

  • mattermost:health [--connection=] — connectivity check. Hits /api/v4/users/me and /api/v4/system/ping, prints a status table (auth ok, ping ok, version, latency).
  • mattermost:post {channel} {message} [--connection=] [--team=] — one-shot post from CLI. Accepts a 26-char channel ID directly or resolves channel-by-name via team lookup.
  • mattermost:listen [--connection=] — start the bot WS listener. Wires the Bot Router to the WebSocket Client, uses signal handling (SIGTERM/SIGINT) for clean shutdown.

All commands support --connection for multi-server named connections. Registered in MattermostServiceProvider::boot() alongside DemoPostCommand.

Test plan

  • Pest BDD tests for all three commands (20 tests, 40 assertions)
  • vendor/bin/pint --test — passed
  • vendor/bin/pest --compact — 283 passed, 14 skipped (integration)
  • vendor/bin/phpstan analyse — no errors (level 8)
  • vendor/bin/rector process --dry-run — no changes

Demo

Demo: http://localhost:8065/jordan-partridge-enterprises-llc/pl/8ghzynca938bfmhdqsy85at5fw

Agent added 2 commits April 27, 2026 01:29
Add three artisan commands for the package:

- mattermost:health — connectivity check hitting /users/me and
  /system/ping, prints a status table with auth, ping, version, latency
- mattermost:post — one-shot CLI post with channel ID or name resolution
  (team lookup when a name is given, direct ID when a 26-char ID is given)
- mattermost:listen — start the bot WebSocket listener with signal
  handling, wiring the Bot Router to the WS client

All commands accept --connection for multi-server support. Registered in
MattermostServiceProvider alongside DemoPostCommand. Includes Pest BDD
tests for each command.
The test was hitting a database cache store without a cache table in the
in-memory SQLite test database.
@jordanpartridge jordanpartridge merged commit 5695070 into main Apr 27, 2026
4 checks passed
@jordanpartridge jordanpartridge deleted the feat/10-artisan-commands branch April 27, 2026 01:34
Copy link
Copy Markdown

@lexi-chief-of-staff lexi-chief-of-staff Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it. Clean artisan commands with good test coverage, nice table output in health, flexible channel resolution in post.

Notes:

  • connectionName() duplicated x3 — extract to trait shared by all commands.
  • ListenCommandTest.php ~lines 12-17: dead assertTrue(... || true) + unused $command + bogus Application::starting() — delete, --help already proves registration.
  • ListenCommandTest ~lines 30-50: tests instantiate deps manually instead of asserting command handle() invokes them with config — mock WebSocketClient::make() / router attach or move to Unit/WebSocketClientTest.php + Unit/RouterTest.php.

All nits; tests pass as-is.

Copy link
Copy Markdown

@lexi-chief-of-staff lexi-chief-of-staff Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it.

  • Artisan commands cover core ops (health check, one-shot post, WS daemon) with smart defaults/multi-connection support.
  • Tests solid: Pest BDD mocks Saloon requests accurately, edge cases (no-team, bad-auth, ID-vs-name) covered.
  • UX table/output intuitive for CLI.

Nit on ListenCommandTest dead assert inline.

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.

feat: Artisan commands — listen, post, health

1 participant