From e1f41b653c8a84b551500b5df472de46c87379cb Mon Sep 17 00:00:00 2001 From: sportshead <32637656+sportshead@users.noreply.github.com> Date: Thu, 28 Jul 2022 18:35:58 +0800 Subject: [PATCH] Add showOutput option to custom commands (#1163) --- pkg/config/user_config.go | 1 + pkg/gui/services/custom_commands/handler_creator.go | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 59bfcc042..804a5bee0 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -310,6 +310,7 @@ type CustomCommand struct { LoadingText string `yaml:"loadingText"` Description string `yaml:"description"` Stream bool `yaml:"stream"` + ShowOutput bool `yaml:"showOutput"` } type CustomCommandPrompt struct { diff --git a/pkg/gui/services/custom_commands/handler_creator.go b/pkg/gui/services/custom_commands/handler_creator.go index 3dd9a0517..b5c2b9efd 100644 --- a/pkg/gui/services/custom_commands/handler_creator.go +++ b/pkg/gui/services/custom_commands/handler_creator.go @@ -187,10 +187,13 @@ func (self *HandlerCreator) finalHandler(customCommand config.CustomCommand, ses if customCommand.Stream { cmdObj.StreamOutput() } - err := cmdObj.Run() + output, err := cmdObj.RunWithOutput() if err != nil { return self.c.Error(err) } + if customCommand.ShowOutput { + return self.c.Alert(cmdStr, output) + } return self.c.Refresh(types.RefreshOptions{}) }) }