Add showOutput option to custom commands (#1163)

This commit is contained in:
sportshead 2022-07-28 18:35:58 +08:00
parent 367b0d3318
commit e1f41b653c
2 changed files with 5 additions and 1 deletions

View file

@ -310,6 +310,7 @@ type CustomCommand struct {
LoadingText string `yaml:"loadingText"` LoadingText string `yaml:"loadingText"`
Description string `yaml:"description"` Description string `yaml:"description"`
Stream bool `yaml:"stream"` Stream bool `yaml:"stream"`
ShowOutput bool `yaml:"showOutput"`
} }
type CustomCommandPrompt struct { type CustomCommandPrompt struct {

View file

@ -187,10 +187,13 @@ func (self *HandlerCreator) finalHandler(customCommand config.CustomCommand, ses
if customCommand.Stream { if customCommand.Stream {
cmdObj.StreamOutput() cmdObj.StreamOutput()
} }
err := cmdObj.Run() output, err := cmdObj.RunWithOutput()
if err != nil { if err != nil {
return self.c.Error(err) return self.c.Error(err)
} }
if customCommand.ShowOutput {
return self.c.Alert(cmdStr, output)
}
return self.c.Refresh(types.RefreshOptions{}) return self.c.Refresh(types.RefreshOptions{})
}) })
} }