Feat: Adds slack docs search subcommand #433
Feat: Adds slack docs search subcommand #433lukegalbraithrussell wants to merge 5 commits intomainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #433 +/- ##
==========================================
+ Coverage 70.27% 70.35% +0.08%
==========================================
Files 220 221 +1
Lines 18498 18559 +61
==========================================
+ Hits 12999 13057 +58
- Misses 4324 4327 +3
Partials 1175 1175 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| const docsSearchAPIURL = "https://docs-slack-d-search-api-duu9zr.herokuapp.com/api/search" |
There was a problem hiding this comment.
This will be updated to docs.slack.dev once api endpoint PR is merged in private docs repo
srtaalej
left a comment
There was a problem hiding this comment.
left some comments about terminal ouput and tests but these changes are looking really good ⭐ ! lets get those addressed so we can merge 😝
| return nil | ||
| } | ||
|
|
||
| func fetchAndOutputSearchResults(ctx context.Context, clients *shared.ClientFactory, query string, limit int, httpClient *http.Client) error { |
There was a problem hiding this comment.
it'd be nice if URLs were full https://docs.slack.dev URLs so they're cmd+clickable in the terminal
{
"url": "https://docs.slack.dev/block-kit/",
"title": "Block Kit"
},right now the json outputs as
{
"url": "/block-kit/",
"title": "Block Kit"
},| { | ||
| "title": "Block Kit", | ||
| "url": "https://docs.slack.dev/block-kit" | ||
| }, |
There was a problem hiding this comment.
these tests are using full URLs in mocks but the real API returns relative paths — so the tests aren't catching this. a simple fix would be to append to the api output.
something like "https://docs.slack.dev" + result.URL
Changelog
Adds
slack docs searchsubcommand. It can output search results as JSONSummary
slack docs search<query>--outputjsonbrowserorjson--limit20Examples
Code coverage notes
The following lines in
search.gohave incomplete test coverage. They seemed cumbersome to cover.(Summarized by Claude)
Lines 88-89 (
if cfg.output == "json"branch): Conditional routing logic that's difficult to test through the command framework. The actual JSON output logic is thoroughly tested via direct function calls.Lines 129-130 (JSON encoding error handling): Defensive error handling for an unrealistic scenario (broken pipe when piping output). Most CLI tools don't explicitly handle this edge case.
Requirements