-
Notifications
You must be signed in to change notification settings - Fork 32
feat: add slack docs search subcommand #433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
f248043
94c8a90
d7bbb84
727d7ce
e1b0d80
4985713
91b5ac5
086b9e5
2bf8133
47613d0
5650feb
671b4c8
0baf948
6c6875e
3317e11
d815e69
1bb0949
2fdee9b
8fd1999
962d75d
fb1c29d
7e615c8
086e69e
b1216f9
e26eab4
2bc9fa7
7a1eacd
f1ca5c3
e89d94d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,136 @@ | ||||||||||
| // Copyright 2022-2026 Salesforce, Inc. | ||||||||||
| // | ||||||||||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||
| // you may not use this file except in compliance with the License. | ||||||||||
| // You may obtain a copy of the License at | ||||||||||
| // | ||||||||||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||
| // | ||||||||||
| // Unless required by applicable law or agreed to in writing, software | ||||||||||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||
| // See the License for the specific language governing permissions and | ||||||||||
| // limitations under the License. | ||||||||||
|
|
||||||||||
| package docs | ||||||||||
|
|
||||||||||
| import ( | ||||||||||
| "context" | ||||||||||
| "encoding/json" | ||||||||||
| "fmt" | ||||||||||
| "net/http" | ||||||||||
| "net/url" | ||||||||||
| "os" | ||||||||||
| "strings" | ||||||||||
|
|
||||||||||
| "github.com/slackapi/slack-cli/internal/shared" | ||||||||||
| "github.com/slackapi/slack-cli/internal/slacktrace" | ||||||||||
| "github.com/slackapi/slack-cli/internal/style" | ||||||||||
| "github.com/spf13/cobra" | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| const docsSearchAPIURL = "https://docs-slack-d-search-api-duu9zr.herokuapp.com/api/search" | ||||||||||
|
||||||||||
| const docsSearchAPIURL = "https://docs-slack-d-search-api-duu9zr.herokuapp.com/api/search" | |
| const docsURL = "https://docs-slack-d-search-api-duu9zr.herokuapp.com/" |
🪬 suggestion: We might want to abstract this to the docs/docs.go file since we target it in multiple places? It might be useful for testing changes too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔬 note: Thanks for also including these as now separate variables:
Line 29 in 671b4c8
| const docsURL = "https://docs.slack.dev" |
slack-cli/internal/api/docs.go
Line 27 in 671b4c8
| const docsSearchAPIURL = "https://docs-slack-d-search-api-duu9zr.herokuapp.com" |
lukegalbraithrussell marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Args: cobra.MinimumNArgs(1), | |
| Args: cobra.MinimumNArgs(0), |
👾 issue: We might want to default to opening the browser if no arguments are provided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zimeg I'm 50/50 on this. if you forget the argument you get yanked into a browser which feels maybe rude?
lukegalbraithrussell marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
lukegalbraithrussell marked this conversation as resolved.
Show resolved
Hide resolved
lukegalbraithrussell marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
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"
},There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📚 thought: I agree listing entire links is ideal and might suggest we add a text format with this?
$ slack docs search "Block Kit" --output=text👾 ramble: If this format is supported it seems awkward to write that flag instead of defaulting to it but this is personal preference I think!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔭 suggestion: Let's prefer to hide deprecated features!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🪓 note: We might now consider breaking this for the next update. I'm starting to think removing these fallbacks can be alright in this PR? @lukegalbraithrussell