mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
Add property outputTitle to CustomCommand
It can optionally be used to set the title of the panel that shows the output of a command (when showOutput is true). If left unset, the command string is used as the title.
This commit is contained in:
@ -0,0 +1,57 @@
|
||||
package custom_commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var ShowOutputInPanel = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Run a command and show the output in a panel",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("my change")
|
||||
},
|
||||
SetupConfig: func(cfg *config.AppConfig) {
|
||||
cfg.UserConfig.CustomCommands = []config.CustomCommand{
|
||||
{
|
||||
Key: "X",
|
||||
Context: "commits",
|
||||
Command: "printf '%s' '{{ .SelectedLocalCommit.Name }}'",
|
||||
ShowOutput: true,
|
||||
},
|
||||
{
|
||||
Key: "Y",
|
||||
Context: "commits",
|
||||
Command: "printf '%s' '{{ .SelectedLocalCommit.Name }}'",
|
||||
ShowOutput: true,
|
||||
OutputTitle: "Subject of commit {{ .SelectedLocalCommit.Hash }}",
|
||||
},
|
||||
}
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("my change").IsSelected(),
|
||||
).
|
||||
Press("X")
|
||||
|
||||
t.ExpectPopup().Alert().
|
||||
// Uses cmd string as title if no outputTitle is provided
|
||||
Title(Equals("printf '%s' 'my change'")).
|
||||
Content(Equals("my change")).
|
||||
Confirm()
|
||||
|
||||
t.Views().Commits().
|
||||
Press("Y")
|
||||
|
||||
hash := t.Git().GetCommitHash("HEAD")
|
||||
t.ExpectPopup().Alert().
|
||||
// Uses provided outputTitle with template fields resolved
|
||||
Title(Equals(fmt.Sprintf("Subject of commit %s", hash))).
|
||||
Content(Equals("my change"))
|
||||
},
|
||||
})
|
Reference in New Issue
Block a user