forked from riba2534/feishu-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat_get.go
More file actions
43 lines (35 loc) · 872 Bytes
/
chat_get.go
File metadata and controls
43 lines (35 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cmd
import (
"github.com/riba2534/feishu-cli/internal/client"
"github.com/riba2534/feishu-cli/internal/config"
"github.com/spf13/cobra"
)
var chatGetCmd = &cobra.Command{
Use: "get <chat_id>",
Short: "获取群聊信息",
Long: `获取指定群聊的详细信息。
参数:
chat_id 群 ID(必填)
示例:
feishu-cli chat get oc_xxx`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if err := config.Validate(); err != nil {
return err
}
token, err := resolveRequiredUserToken(cmd)
if err != nil {
return err
}
chatID := args[0]
data, err := client.GetChat(chatID, token)
if err != nil {
return err
}
return printJSON(data)
},
}
func init() {
chatCmd.AddCommand(chatGetCmd)
chatGetCmd.Flags().String("user-access-token", "", "User Access Token(用户授权令牌)")
}