Includes mmctl into the mono-repo (#23091)
* Includes mmctl into the mono-repo * Update to use the new public module paths * Adds docs check to the mmctl CI * Fix public utils import path * Tidy up modules * Fix linter * Update CI tasks to use the new file structure * Update CI references
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
412109b02e
Коммит
951456c780
44
server/cmd/mmctl/commands/websockets.go
Обычный файл
44
server/cmd/mmctl/commands/websockets.go
Обычный файл
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var WebsocketCmd = &cobra.Command{
|
||||
Use: "websocket",
|
||||
Short: "Display websocket in a human-readable format",
|
||||
RunE: websocketCmdF,
|
||||
}
|
||||
|
||||
func init() {
|
||||
RootCmd.AddCommand(WebsocketCmd)
|
||||
}
|
||||
|
||||
func websocketCmdF(cmd *cobra.Command, args []string) error {
|
||||
c, err := InitWebSocketClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
appErr := c.Connect()
|
||||
if appErr != nil {
|
||||
return errors.New(appErr.Error())
|
||||
}
|
||||
|
||||
c.Listen()
|
||||
fmt.Println("Press CTRL+C to exit")
|
||||
for {
|
||||
event := <-c.EventChannel
|
||||
data, err := event.ToJSON()
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
} else {
|
||||
fmt.Println(string(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user