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
55
server/cmd/mmctl/commands/commandargs.go
Обычный файл
55
server/cmd/mmctl/commands/commandargs.go
Обычный файл
@@ -0,0 +1,55 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package commands
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/mattermost/mattermost-server/server/v8/cmd/mmctl/client"
|
||||
|
||||
"github.com/mattermost/mattermost-server/server/public/model"
|
||||
)
|
||||
|
||||
// getCommandFromCommandArg retrieves a Command by command id or team:trigger.
|
||||
func getCommandFromCommandArg(c client.Client, commandArg string) *model.Command {
|
||||
if checkSlash(commandArg) {
|
||||
return nil
|
||||
}
|
||||
|
||||
cmd := getCommandFromTeamTrigger(c, commandArg)
|
||||
if cmd == nil {
|
||||
cmd, _, _ = c.GetCommandById(commandArg)
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
|
||||
// getCommandFromTeamTrigger retrieves a Command via team:trigger syntax.
|
||||
func getCommandFromTeamTrigger(c client.Client, teamTrigger string) *model.Command {
|
||||
arr := strings.Split(teamTrigger, ":")
|
||||
if len(arr) != 2 {
|
||||
return nil
|
||||
}
|
||||
|
||||
team, _, _ := c.GetTeamByName(arr[0], "")
|
||||
if team == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
trigger := arr[1]
|
||||
if trigger == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
list, _, _ := c.ListCommands(team.Id, false)
|
||||
if list == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, cmd := range list {
|
||||
if cmd.Trigger == trigger {
|
||||
return cmd
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Ссылка в новой задаче
Block a user