Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ The CLI will always use the version of the `python-slack-hooks` that is specifie

### Supported Hooks

The hooks currently supported for use within the Slack CLI include `check-update`, `get-hooks`, `get-manifest`, and `start`:
The hooks currently supported for use within the Slack CLI include `check-update`, `doctor`, `get-hooks`, `get-manifest`, and `start`:

| Hook Name | CLI Command | File | Description |
| --- | --- | --- | --- |
| `check-update` | `slack update` | [check_update.py](./slack_cli_hooks/hooks/check_update.py) | Checks the project's Slack dependencies to determine whether or not any libraries need to be updated. |
| `doctor` | `slack doctor` | [doctor.py](./slack_cli_hooks/hooks/doctor.py) | Returns runtime versions and other system dependencies required by the application. |
| `get-hooks` | All | [get_hooks.py](./slack_cli_hooks/hooks/get_hooks.py) | Fetches the list of available hooks for the CLI from this repository. |
| `get-manifest` | `slack manifest` | [get_manifest.py](./slack_cli_hooks/hooks/get_manifest.py) | Converts a `manifest.json` file into a valid manifest JSON payload. |
| `start` | `slack run` | [start.py](./slack_cli_hooks/hooks/start.py) | While developing locally, the CLI manages a socket connection with Slack's backend and utilizes this hook for events received via this connection. |
Expand Down
32 changes: 32 additions & 0 deletions slack_cli_hooks/hooks/doctor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python
import json
import platform

from slack_cli_hooks.protocol import (
Protocol,
build_protocol,
)

PROTOCOL: Protocol


doctor_payload = {
"versions": [
{
"name": "python",
"current": platform.python_version(),
},
{
"name": "implementation",
"current": platform.python_implementation(),
},
{
"name": "compiler",
"current": platform.python_compiler(),
Copy link
Contributor

Choose a reason for hiding this comment

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

The python_compiler() is said to identify the compiler used for compiling Python. I don't think this will be very informative, unless a developer is compiling their own version of python (if they are, not sure how we could help them)

Providing the system information with platform.system() may be more informative for maintainers try to and help a developer, let me know what you think

Copy link
Member Author

Choose a reason for hiding this comment

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

Open to removing this if you don't think it'd be useful. I was honestly looking to make a group of three and the compiler seemed interesting 👀

The system OS and architecture is also included a bit early in the doctor output and I think would be the same for the platform.system()? I really hope at least 😳 So this base might be covered already 🙌

Copy link
Contributor

Choose a reason for hiding this comment

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

The system OS and architecture is also included a bit early in the doctor output and I think would be the same for the platform.system()? I really hope at least 😳 So this base might be covered already 🙌

Just saw it now 👍 alternatively platform.platform() yields a string similar to this on my machine macOS-14.4-arm64-arm-64bit if this information if not outputted by the CLI already I think it would be more useful then python_compiler()

But if it is python_compiler() can fill the 3rd item

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the GOOS / GOARCH covers the platform well enough for debugging purposes! Going to keep the compiler here for the time being

},
],
}

if __name__ == "__main__":
PROTOCOL = build_protocol()
PROTOCOL.respond(json.dumps(doctor_payload))
1 change: 1 addition & 0 deletions slack_cli_hooks/hooks/get_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"get-manifest": f"{EXEC} -m slack_cli_hooks.hooks.get_manifest",
"start": f"{EXEC} -X dev -m slack_cli_hooks.hooks.start",
"check-update": f"{EXEC} -m slack_cli_hooks.hooks.check_update",
"doctor": f"{EXEC} -m slack_cli_hooks.hooks.doctor",
},
"config": {
"watch": {"filter-regex": "(^manifest\\.json$)", "paths": ["."]},
Expand Down
16 changes: 16 additions & 0 deletions tests/slack_cli_hooks/hooks/test_doctor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import platform

from slack_cli_hooks.hooks.doctor import doctor_payload


class TestDoctor:
def test_versions(self):
versions = doctor_payload.get("versions")
assert versions is not None

assert versions[0].get("name") == "python"
assert versions[0].get("current") == platform.python_version()
assert versions[1].get("name") == "implementation"
assert versions[1].get("current") == platform.python_implementation()
assert versions[2].get("name") == "compiler"
assert versions[2].get("current") == platform.python_compiler()
1 change: 1 addition & 0 deletions tests/slack_cli_hooks/hooks/test_get_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def test_hooks_payload(self):
assert "slack_cli_hooks.hooks.get_manifest" in hooks["get-manifest"]
assert "slack_cli_hooks.hooks.start" in hooks["start"]
assert "slack_cli_hooks.hooks.check_update" in hooks["check-update"]
assert "slack_cli_hooks.hooks.doctor" in hooks["doctor"]

def test_hooks_payload_config(self):
config = hooks_payload["config"]
Expand Down