Skip to content

Feat: Adds slack docs search subcommand #433

Open
lukegalbraithrussell wants to merge 5 commits intomainfrom
docs-search-subcommand
Open

Feat: Adds slack docs search subcommand #433
lukegalbraithrussell wants to merge 5 commits intomainfrom
docs-search-subcommand

Conversation

@lukegalbraithrussell
Copy link
Contributor

@lukegalbraithrussell lukegalbraithrussell commented Mar 24, 2026

Changelog

Adds slack docs search subcommand. It can output search results as JSON

Summary

slack docs search

Option Type Default Description Required
<query> string Search terms Required
--output string json Output format: browser or json Optional
--limit int 20 Max number of results to return (JSON output only) Optional

Examples

# Search and return JSON results
$ slack-cli docs search "Block Kit"

# Search and return JSON results with custom result limit
$ slack-cli docs search "api" --limit=5

# Search and open results in browser
$ slack-cli docs search "webhooks" --output=browser

Code coverage notes

The following lines in search.go have 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

@lukegalbraithrussell lukegalbraithrussell changed the title go Feat: Adds slack docs search subcommand Mar 24, 2026
@codecov
Copy link

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 93.93939% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.35%. Comparing base (97fbfe8) to head (e1b0d80).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/docs/search.go 93.10% 2 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

"github.com/spf13/cobra"
)

const docsSearchAPIURL = "https://docs-slack-d-search-api-duu9zr.herokuapp.com/api/search"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be updated to docs.slack.dev once api endpoint PR is merged in private docs repo

@lukegalbraithrussell lukegalbraithrussell marked this pull request as ready for review March 24, 2026 17:25
@lukegalbraithrussell lukegalbraithrussell requested a review from a team as a code owner March 24, 2026 17:25
Copy link
Contributor

@srtaalej srtaalej left a comment

Choose a reason for hiding this comment

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

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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

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"
    },

Comment on lines +148 to +151
{
"title": "Block Kit",
"url": "https://docs.slack.dev/block-kit"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

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

@srtaalej srtaalej added docs M-T: Documentation work only enhancement M-T: A feature request for new functionality semver:minor Use on pull requests to describe the release version increment labels Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs M-T: Documentation work only enhancement M-T: A feature request for new functionality semver:minor Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants