Skip to content

feat: adds docs command with optional search flag#352

Open
lukegalbraithrussell wants to merge 13 commits intomainfrom
docs-command
Open

feat: adds docs command with optional search flag#352
lukegalbraithrussell wants to merge 13 commits intomainfrom
docs-command

Conversation

@lukegalbraithrussell
Copy link
Contributor

@lukegalbraithrussell lukegalbraithrussell commented Feb 24, 2026

Changelog

The slack docs command opens the slack docs site; its --search flag opens the slack docs search page with the provided search query.

Summary

This PR adds a docs command.

Command Result
slack docs opens docs.slack.dev
slack docs --search opens docs.slack.dev/search
slack docs --search "something cool" docs.slack.dev/search/?q=something+cool
slack docs "something cool" docs.slack.dev/search/?q=something+cool

This doesn't take advantage of the charm experiment. Next steps though!!!

Requirements

@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.67%. Comparing base (1059ec2) to head (35153a9).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #352      +/-   ##
==========================================
+ Coverage   64.48%   64.67%   +0.18%     
==========================================
  Files         213      214       +1     
  Lines       17879    17974      +95     
==========================================
+ Hits        11530    11625      +95     
+ Misses       5276     5272       -4     
- Partials     1073     1077       +4     

☔ 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.

@lukegalbraithrussell lukegalbraithrussell changed the title Feat: adds docs command with optional search param Feat: adds docs command with optional search flag Feb 25, 2026
"github.com/stretchr/testify/mock"
)

func Test_Docs_DocsCommand(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

valid if these are too many tests lol

Copy link
Member

Choose a reason for hiding this comment

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

@lukegalbraithrussell These are solid cases to cover! It makes me confident that we're covering edge cases from the start 🤓

@lukegalbraithrussell lukegalbraithrussell marked this pull request as ready for review February 25, 2026 17:27
@lukegalbraithrussell lukegalbraithrussell requested a review from a team as a code owner February 25, 2026 17:27
Copy link
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

☕️ Leaving a few notes from the coffee shop-

cmd/docs/docs.go Outdated

clients.Browser().OpenURL(docsURL)

// Add trace for analytics
Copy link
Member

Choose a reason for hiding this comment

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

🧪 note: We use these traces for testing certain paths are reached in our E2E tests:

$ SLACK_TEST_TRACE=1 slack docs

It might be nice to update or remove this comment to avoid ongoing confusion toward this!

Comment on lines +73 to +79
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
Emoji: "books",
Text: sectionText,
Secondary: []string{
docsURL,
},
}))
Copy link
Member

@zimeg zimeg Feb 26, 2026

Choose a reason for hiding this comment

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

📠 suggestion: Our sytles are not so consistent but we might want to use the command name for "text" with more details following?

📚 Docs Open
   https://docs.slack.dev/

Or

📚 Docs Search
   https://docs.slack.dev/search?q=chatbot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

super good point! changed it

"github.com/stretchr/testify/mock"
)

func Test_Docs_DocsCommand(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

@lukegalbraithrussell These are solid cases to cover! It makes me confident that we're covering edge cases from the start 🤓

@zimeg zimeg changed the title Feat: adds docs command with optional search flag feat: adds docs command with optional search flag Feb 26, 2026
@zimeg zimeg added enhancement M-T: A feature request for new functionality changelog Use on updates to be included in the release notes semver:minor Use on pull requests to describe the release version increment labels Feb 26, 2026
@zimeg zimeg added this to the Next Release milestone Feb 26, 2026
@lukegalbraithrussell
Copy link
Contributor Author

@zimeg thank you kindly for the coffee shop review. i've updated per your suggestion (while drinking coffee but at home alas)

Copy link
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

@lukegalbraithrussell I appreciate the fast changes! Coffee finds me good too in the office ☕ ✨

I'm leaving a few more comments about the standalone search patterns. This is a smooth path to a familiar search experience that I'd like to support, but feel free to hold off on those changes if it's not envisioned 👁️‍🗨️

Comment on lines 91 to 102
"handles empty search query as homepage": {
CmdArgs: []string{"--search", ""},
ExpectedAsserts: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock) {
expectedURL := "https://docs.slack.dev"
cm.Browser.AssertCalled(t, "OpenURL", expectedURL)
cm.IO.AssertCalled(t, "PrintTrace", mock.Anything, slacktrace.DocsSuccess, mock.Anything)
},
ExpectedOutputs: []string{
"Docs Open",
"https://docs.slack.dev",
},
},
Copy link
Member

Choose a reason for hiding this comment

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

🧪 issue: This case is a bit misleading to me! I tried using the search flag without an argument to find this error:

$ slack docs --search
Check /Users/eden.zimbelman/.slack/logs/slack-debug-20260226.log for error logs
flag needs an argument: --search

should this instead open docs.slack.dev/search?

I do think this would be ideal - perhaps "https://docs.slack.dev/search/" complete - if possible, without an argument?

{Command: "init", Meaning: "Initialize an existing Slack app"},
{Command: "run", Meaning: "Start a local development server"},
{Command: "deploy", Meaning: "Deploy to the Slack Platform"},
{Command: "docs", Meaning: "Open Slack developer docs"},
Copy link
Member

Choose a reason for hiding this comment

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

📚 praise: This is nice to find toward the bottom of help alongside other calls to action!

cmd/docs/docs.go Outdated
},
}

cmd.Flags().StringVar(&searchFlag, "search", "", "search query for Slack docs")
Copy link
Member

Choose a reason for hiding this comment

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

🪬 suggestion: Related to the "required" search value if the "--search" flag is provided - I wonder if we can change this to be a "boolean" value?

This might allow this command to accept 1 argument instead of 0 for sake of being the search query? We might then search if that flag is provided or if an argument is used:

$ slack docs --search
$ slack docs "Block Kit"
$ slack docs --search "Block Kit"

We ought not need to document the second case IMHO since it's identical to the third, and I don't think such approach limits future changes. Not a blocker here but the examples might need updating before merge!

Copy link
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

💡 @lukegalbraithrussell This is getting so good! I'm leaving one more comment of edge cases found, but I'm so optimistic!

var sectionText string

// Validate: if there are arguments, --search flag must be used
if len(args) > 0 && !cmd.Flags().Changed("search") {
Copy link
Member

Choose a reason for hiding this comment

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

🪬 suggestion: We might still want to keep a max arguments setting for this command, but set to 1. It can be confusing otherwise to find:

(.venv) $ lack docs --search one two

📚 Docs Search
   https://docs.slack.dev/search/?q=one

Although we can also update this section with "variadic" arguments to join the arguments together - IMHO this might be ideal if not so complicated 👻

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

Labels

changelog Use on updates to be included in the release notes 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