feat: adds docs command with optional search flag#352
feat: adds docs command with optional search flag#352lukegalbraithrussell wants to merge 13 commits intomainfrom
docs command with optional search flag#352Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
docs command with optional search paramdocs command with optional search flag
| "github.com/stretchr/testify/mock" | ||
| ) | ||
|
|
||
| func Test_Docs_DocsCommand(t *testing.T) { |
There was a problem hiding this comment.
valid if these are too many tests lol
There was a problem hiding this comment.
@lukegalbraithrussell These are solid cases to cover! It makes me confident that we're covering edge cases from the start 🤓
zimeg
left a comment
There was a problem hiding this comment.
☕️ Leaving a few notes from the coffee shop-
cmd/docs/docs.go
Outdated
|
|
||
| clients.Browser().OpenURL(docsURL) | ||
|
|
||
| // Add trace for analytics |
There was a problem hiding this comment.
🧪 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!
| clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{ | ||
| Emoji: "books", | ||
| Text: sectionText, | ||
| Secondary: []string{ | ||
| docsURL, | ||
| }, | ||
| })) |
There was a problem hiding this comment.
📠 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
There was a problem hiding this comment.
super good point! changed it
| "github.com/stretchr/testify/mock" | ||
| ) | ||
|
|
||
| func Test_Docs_DocsCommand(t *testing.T) { |
There was a problem hiding this comment.
@lukegalbraithrussell These are solid cases to cover! It makes me confident that we're covering edge cases from the start 🤓
docs command with optional search flagdocs command with optional search flag
|
@zimeg thank you kindly for the coffee shop review. i've updated per your suggestion (while drinking coffee but at home alas) |
zimeg
left a comment
There was a problem hiding this comment.
@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 👁️🗨️
cmd/docs/docs_test.go
Outdated
| "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", | ||
| }, | ||
| }, |
There was a problem hiding this comment.
🧪 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"}, |
There was a problem hiding this comment.
📚 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") |
There was a problem hiding this comment.
🪬 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!
zimeg
left a comment
There was a problem hiding this comment.
💡 @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") { |
There was a problem hiding this comment.
🪬 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 👻
Changelog
The
slack docscommand opens the slack docs site; its--searchflag opens the slack docs search page with the provided search query.Summary
This PR adds a
docscommand.slack docsdocs.slack.devslack docs --searchdocs.slack.dev/searchslack docs --search "something cool"docs.slack.dev/search/?q=something+coolslack docs "something cool"docs.slack.dev/search/?q=something+coolThis doesn't take advantage of the charm experiment. Next steps though!!!
Requirements