Combine customCommand's subprocess, stream, and showOutput fields into a single output enum

This commit is contained in:
Stefan Haller 2025-04-30 17:13:33 +02:00
parent 5f4be3bfb7
commit a9f9dee30d
9 changed files with 187 additions and 43 deletions

View file

@ -262,7 +262,7 @@ func (self *HandlerCreator) finalHandler(customCommand config.CustomCommand, ses
cmdObj := self.c.OS().Cmd.NewShell(cmdStr, self.c.UserConfig().OS.ShellFunctionsFile)
if customCommand.Subprocess != nil && *customCommand.Subprocess {
if customCommand.Output == "terminal" {
return self.c.RunSubprocessAndRefresh(cmdObj)
}
@ -274,9 +274,12 @@ func (self *HandlerCreator) finalHandler(customCommand config.CustomCommand, ses
return self.c.WithWaitingStatus(loadingText, func(gocui.Task) error {
self.c.LogAction(self.c.Tr.Actions.CustomCommand)
if customCommand.Stream != nil && *customCommand.Stream {
if customCommand.Output == "log" || customCommand.Output == "logWithPty" {
cmdObj.StreamOutput()
}
if customCommand.Output == "logWithPty" {
cmdObj.UsePty()
}
output, err := cmdObj.RunWithOutput()
if refreshErr := self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}); err != nil {
@ -291,7 +294,7 @@ func (self *HandlerCreator) finalHandler(customCommand config.CustomCommand, ses
return err
}
if customCommand.ShowOutput != nil && *customCommand.ShowOutput {
if customCommand.Output == "popup" {
if strings.TrimSpace(output) == "" {
output = self.c.Tr.EmptyOutput
}