custom_commands

package
v0.51.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2025 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccessCommitProperties = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Run a command that accesses properties of a commit",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("my change")
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "X",
				Context: "commits",
				Command: "printf '%s\n%s\n%s' '{{ .SelectedLocalCommit.Name }}' '{{ .SelectedLocalCommit.Hash }}' '{{ .SelectedLocalCommit.Sha }}' > file.txt",
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().
			Focus().
			Lines(
				Contains("my change").IsSelected(),
			).
			Press("X")

		hash := t.Git().GetCommitHash("HEAD")
		t.FileSystem().FileContent("file.txt", Equals(fmt.Sprintf("my change\n%s\n%s", hash, hash)))
	},
})
View Source
var BasicCommand = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Using a custom command to create a new file",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("blah")
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "a",
				Context: "files",
				Command: "touch myfile",
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().
			IsEmpty().
			IsFocused().
			Press("a").
			Lines(
				Contains("myfile"),
			)
	},
})
View Source
var CheckForConflicts = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Run a command and check for conflicts after",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shared.MergeConflictsSetup(shell)
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "m",
				Context: "localBranches",
				Command: "git merge {{ .SelectedLocalBranch.Name | quote }}",
				After: &config.CustomCommandAfterHook{
					CheckForConflicts: true,
				},
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			TopLines(
				Contains("first-change-branch"),
				Contains("second-change-branch"),
			).
			NavigateToLine(Contains("second-change-branch")).
			Press("m")

		t.Common().AcknowledgeConflicts()
	},
})
View Source
var CustomCommandsSubmenu = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Using custom commands from a custom commands menu",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo:    func(shell *Shell) {},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:         "x",
				Description: "My Custom Commands",
				CommandMenu: []config.CustomCommand{
					{
						Key:     "1",
						Context: "global",
						Command: "touch myfile-global",
					},
					{
						Key:     "2",
						Context: "files",
						Command: "touch myfile-files",
					},
					{
						Key:     "3",
						Context: "commits",
						Command: "touch myfile-commits",
					},
				},
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().
			Focus().
			IsEmpty().
			Press("x").
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("My Custom Commands")).
					Lines(
						Contains("1 touch myfile-global"),
						Contains("2 touch myfile-files"),
					).
					Select(Contains("touch myfile-files")).Confirm()
			}).
			Lines(
				Contains("myfile-files"),
			)

		t.Views().Commits().
			Focus().
			Press("x").
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("My Custom Commands")).
					Lines(
						Contains("1 touch myfile-global"),
						Contains("3 touch myfile-commits"),
					)
				t.GlobalPress("3")
			})

		t.Views().Files().
			Lines(
				Equals("▼ /"),
				Contains("myfile-commits"),
				Contains("myfile-files"),
			)
	},
})
View Source
var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Using a custom command referring prompt responses by name",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("blah")
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "a",
				Context: "files",
				Command: `echo {{.Form.FileContent | quote}} > {{.Form.FileName | quote}}`,
				Prompts: []config.CustomCommandPrompt{
					{
						Key:   "FileName",
						Type:  "input",
						Title: "Enter a file name",
					},
					{
						Key:   "FileContent",
						Type:  "menu",
						Title: "Choose file content",
						Options: []config.CustomCommandMenuOption{
							{
								Name:        "foo",
								Description: "Foo",
								Value:       "FOO",
							},
							{
								Name:        "bar",
								Description: "Bar",
								Value:       `"BAR"`,
							},
							{
								Name:        "baz",
								Description: "Baz",
								Value:       "BAZ",
							},
						},
					},
					{
						Type:  "confirm",
						Title: "Are you sure?",
						Body:  "Are you REALLY sure you want to make this file? Up to you buddy.",
					},
				},
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().
			IsEmpty().
			IsFocused().
			Press("a")

		t.ExpectPopup().Prompt().Title(Equals("Enter a file name")).Type("my file").Confirm()

		t.ExpectPopup().Menu().Title(Equals("Choose file content")).Select(Contains("bar")).Confirm()

		t.ExpectPopup().Confirmation().
			Title(Equals("Are you sure?")).
			Content(Equals("Are you REALLY sure you want to make this file? Up to you buddy.")).
			Confirm()

		t.Views().Files().
			Lines(
				Contains("my file").IsSelected(),
			)

		t.Views().Main().Content(Contains(`"BAR"`))
	},
})
View Source
var GlobalContext = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Ensure global context works",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("my change")
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "X",
				Context: "global",
				Command: "touch myfile",
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {

		t.Views().Commits().
			Focus().
			Press("X")

		t.Views().Files().
			Focus().
			Lines(Contains("myfile"))

		t.Shell().DeleteFile("myfile")
		t.GlobalPress(keys.Files.RefreshFiles)

		t.Views().Branches().
			Focus().
			Press("X")

		t.Views().Files().
			Focus().
			Lines(Contains("myfile"))

		t.Shell().DeleteFile("myfile")
		t.GlobalPress(keys.Files.RefreshFiles)

		t.Views().Files().
			Focus().
			Press("X")

		t.Views().Files().
			Focus().
			Lines(Contains("myfile"))

		t.Shell().DeleteFile("myfile")
	},
})
View Source
var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Using menuFromCommand prompt type",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.
			EmptyCommit("foo").
			EmptyCommit("bar").
			EmptyCommit("baz").
			NewBranch("feature/foo")
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "a",
				Context: "localBranches",
				Command: `echo "{{index .PromptResponses 0}} {{index .PromptResponses 1}} {{ .SelectedLocalBranch.Name }}" > output.txt`,
				Prompts: []config.CustomCommandPrompt{
					{
						Type:        "menuFromCommand",
						Title:       "Choose commit message",
						Command:     `git log --oneline --pretty=%B`,
						Filter:      `(?P<commit_message>.*)`,
						ValueFormat: `{{ .commit_message }}`,
						LabelFormat: `{{ .commit_message | yellow }}`,
					},
					{
						Type:         "input",
						Title:        "Description",
						InitialValue: `{{ if .SelectedLocalBranch.Name }}Branch: #{{ .SelectedLocalBranch.Name }}{{end}}`,
					},
				},
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().
			IsEmpty()

		t.Views().Branches().
			Focus().
			Press("a")

		t.ExpectPopup().Menu().Title(Equals("Choose commit message")).Select(Contains("bar")).Confirm()

		t.ExpectPopup().Prompt().Title(Equals("Description")).Type(" my branch").Confirm()

		t.Views().Files().
			Focus().
			Lines(
				Contains("output.txt").IsSelected(),
			)

		t.Views().Main().Content(Contains("bar Branch: #feature/foo my branch feature/foo"))
	},
})
View Source
var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Using prompt response in menuFromCommand entries",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.
			EmptyCommit("foo").
			NewBranch("feature/foo").
			EmptyCommit("bar").
			NewBranch("feature/bar").
			EmptyCommit("baz")
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "a",
				Context: "localBranches",
				Command: "git checkout {{ index .PromptResponses 1 }}",
				Prompts: []config.CustomCommandPrompt{
					{
						Type:         "input",
						Title:        "Which git command do you want to run?",
						InitialValue: "branch",
					},
					{
						Type:        "menuFromCommand",
						Title:       "Branch:",
						Command:     `git {{ index .PromptResponses 0 }} --format='%(refname:short)'`,
						Filter:      "(?P<branch>.*)",
						ValueFormat: `{{ .branch }}`,
						LabelFormat: `{{ .branch | green }}`,
					},
				},
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Git().CurrentBranchName("feature/bar")

		t.Views().Branches().
			Focus().
			Press("a")

		t.ExpectPopup().Prompt().
			Title(Equals("Which git command do you want to run?")).
			InitialText(Equals("branch")).
			Confirm()

		t.ExpectPopup().Menu().Title(Equals("Branch:")).Select(Equals("master")).Confirm()

		t.Git().CurrentBranchName("master")
	},
})
View Source
var MultipleContexts = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Test that multiple contexts works",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("my change")
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "X",
				Context: "commits, reflogCommits",
				Command: "touch myfile",
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {

		t.Views().Commits().
			Focus().
			Press("X")

		t.Views().Files().
			Focus().
			Lines(Contains("myfile"))

		t.Shell().DeleteFile("myfile")
		t.GlobalPress(keys.Files.RefreshFiles)

		t.Views().Branches().
			Focus().
			Press("X")

		t.Views().Files().
			Focus().
			IsEmpty()

		t.Views().ReflogCommits().
			Focus().
			Press("X")

		t.Views().Files().
			Focus().
			Lines(Contains("myfile"))

		t.Shell().DeleteFile("myfile")
	},
})
View Source
var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Using a custom command with multiple prompts",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("blah")
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "a",
				Context: "files",
				Command: `echo "{{index .PromptResponses 1}}" > {{index .PromptResponses 0}}`,
				Prompts: []config.CustomCommandPrompt{
					{
						Type:  "input",
						Title: "Enter a file name",
					},
					{
						Type:  "menu",
						Title: "Choose file content",
						Options: []config.CustomCommandMenuOption{
							{
								Name:        "foo",
								Description: "Foo",
								Value:       "FOO",
							},
							{
								Name:        "bar",
								Description: "Bar",
								Value:       "BAR",
							},
							{
								Name:        "baz",
								Description: "Baz",
								Value:       "BAZ",
							},
						},
					},
					{
						Type:  "confirm",
						Title: "Are you sure?",
						Body:  "Are you REALLY sure you want to make this file? Up to you buddy.",
					},
				},
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().
			IsEmpty().
			IsFocused().
			Press("a")

		t.ExpectPopup().Prompt().Title(Equals("Enter a file name")).Type("myfile").Confirm()

		t.ExpectPopup().Menu().Title(Equals("Choose file content")).Select(Contains("bar")).Confirm()

		t.ExpectPopup().Confirmation().
			Title(Equals("Are you sure?")).
			Content(Equals("Are you REALLY sure you want to make this file? Up to you buddy.")).
			Confirm()

		t.Views().Files().
			Focus().
			Lines(
				Contains("myfile").IsSelected(),
			)

		t.Views().Main().Content(Contains("BAR"))
	},
})
View Source
var RunCommand = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Using a custom command that uses runCommand template function in a prompt step",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("blah")
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "a",
				Context: "localBranches",
				Command: `git checkout {{.Form.Branch}}`,
				Prompts: []config.CustomCommandPrompt{
					{
						Key:          "Branch",
						Type:         "input",
						Title:        "Enter a branch name",
						InitialValue: "myprefix/{{ runCommand \"echo dynamic\" }}/",
					},
				},
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Press("a")

		t.ExpectPopup().Prompt().
			Title(Equals("Enter a branch name")).
			InitialText(Contains("myprefix/dynamic/")).
			Confirm()
	},
})
View Source
var SelectedCommit = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Use the {{ .SelectedCommit }} template variable in different contexts",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.CreateNCommits(3)
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "X",
				Context: "global",
				Command: "printf '%s' '{{ .SelectedCommit.Name }}' > file.txt",
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {

		t.Views().Commits().Focus().
			NavigateToLine(Contains("commit 01"))
		t.Views().ReflogCommits().Focus().
			NavigateToLine(Contains("commit 02"))
		t.Views().Branches().Focus().
			Lines(Contains("master").IsSelected()).
			PressEnter()
		t.Views().SubCommits().IsFocused().
			NavigateToLine(Contains("commit 03"))

		t.GlobalPress("X")
		t.FileSystem().FileContent("file.txt", Equals("commit 03"))

		t.Views().SubCommits().PressEnter()
		t.GlobalPress("X")
		t.FileSystem().FileContent("file.txt", Equals("commit 03"))

		t.Views().ReflogCommits().Focus()
		t.GlobalPress("X")
		t.FileSystem().FileContent("file.txt", Equals("commit: commit 02"))

		t.Views().ReflogCommits().PressEnter()
		t.GlobalPress("X")
		t.FileSystem().FileContent("file.txt", Equals("commit: commit 02"))

		t.Views().Commits().Focus()
		t.GlobalPress("X")
		t.FileSystem().FileContent("file.txt", Equals("commit 01"))

		t.Views().Commits().PressEnter()
		t.GlobalPress("X")
		t.FileSystem().FileContent("file.txt", Equals("commit 01"))

		t.Views().Files().Focus()
		t.GlobalPress("X")
		t.FileSystem().FileContent("file.txt", Equals("commit 01"))
	},
})
View Source
var SelectedCommitRange = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Use the {{ .SelectedCommitRange }} template variable",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.CreateNCommits(3)
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "X",
				Context: "global",
				Command: `git log --format="%s" {{.SelectedCommitRange.From}}^..{{.SelectedCommitRange.To}} > file.txt`,
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().Focus().
			Lines(
				Contains("commit 03").IsSelected(),
				Contains("commit 02"),
				Contains("commit 01"),
			)

		t.GlobalPress("X")
		t.FileSystem().FileContent("file.txt", Equals("commit 03\n"))

		t.Views().Commits().Focus().
			Press(keys.Universal.RangeSelectDown)

		t.GlobalPress("X")
		t.FileSystem().FileContent("file.txt", Equals("commit 03\ncommit 02\n"))
	},
})
View Source
var SelectedPath = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Use the {{ .SelectedPath }} template variable in different contexts",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.CreateDir("folder1")
		shell.CreateFileAndAdd("folder1/file1", "")
		shell.Commit("commit")
		shell.CreateDir("folder2")
		shell.CreateFile("folder2/file2", "")
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "X",
				Context: "global",
				Command: "printf '%s' '{{ .SelectedPath }}' > file.txt",
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().
			Focus().
			NavigateToLine(Contains("file2"))
		t.GlobalPress("X")
		t.FileSystem().FileContent("file.txt", Equals("folder2/file2"))

		t.Views().Commits().
			Focus().
			PressEnter()
		t.Views().CommitFiles().
			IsFocused().
			NavigateToLine(Contains("file1"))
		t.GlobalPress("X")
		t.FileSystem().FileContent("file.txt", Equals("folder1/file1"))
	},
})
View Source
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.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "X",
				Context: "commits",
				Command: "printf '%s' '{{ .SelectedLocalCommit.Name }}'",
				Output:  "popup",
			},
			{
				Key:         "Y",
				Context:     "commits",
				Command:     "printf '%s' '{{ .SelectedLocalCommit.Name }}'",
				Output:      "popup",
				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().
			Title(Equals("printf '%s' 'my change'")).
			Content(Equals("my change")).
			Confirm()

		t.Views().Commits().
			Press("Y")

		hash := t.Git().GetCommitHash("HEAD")
		t.ExpectPopup().Alert().
			Title(Equals(fmt.Sprintf("Subject of commit %s", hash))).
			Content(Equals("my change"))
	},
})
View Source
var SuggestionsCommand = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Using a custom command that uses a suggestions command in a prompt step",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.NewBranch("branch-one")
		shell.EmptyCommit("blah")
		shell.NewBranch("branch-two")
		shell.EmptyCommit("blah")
		shell.NewBranch("branch-three")
		shell.EmptyCommit("blah")
		shell.NewBranch("branch-four")
		shell.EmptyCommit("blah")
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "a",
				Context: "localBranches",
				Command: `git checkout {{.Form.Branch}}`,
				Prompts: []config.CustomCommandPrompt{
					{
						Key:   "Branch",
						Type:  "input",
						Title: "Enter a branch name",
						Suggestions: config.CustomCommandSuggestions{
							Command: "git branch --format='%(refname:short)'",
						},
					},
				},
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains("branch-four").IsSelected(),
				Contains("branch-three"),
				Contains("branch-two"),
				Contains("branch-one"),
			).
			Press("a")

		t.ExpectPopup().Prompt().
			Title(Equals("Enter a branch name")).
			Type("three").
			SuggestionLines(Contains("branch-three")).
			ConfirmFirstSuggestion()

		t.Views().Branches().
			Lines(
				Contains("branch-three"),
				Contains("branch-four").IsSelected(),
				Contains("branch-two"),
				Contains("branch-one"),
			)
	},
})
View Source
var SuggestionsPreset = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Using a custom command that uses a suggestions preset in a prompt step",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupRepo: func(shell *Shell) {
		shell.NewBranch("branch-one")
		shell.EmptyCommit("blah")
		shell.NewBranch("branch-two")
		shell.EmptyCommit("blah")
		shell.NewBranch("branch-three")
		shell.EmptyCommit("blah")
		shell.NewBranch("branch-four")
		shell.EmptyCommit("blah")
	},
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     "a",
				Context: "localBranches",
				Command: `git checkout {{.Form.Branch}}`,
				Prompts: []config.CustomCommandPrompt{
					{
						Key:   "Branch",
						Type:  "input",
						Title: "Enter a branch name",
						Suggestions: config.CustomCommandSuggestions{
							Preset: "branches",
						},
					},
				},
			},
		}
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains("branch-four").IsSelected(),
				Contains("branch-three"),
				Contains("branch-two"),
				Contains("branch-one"),
			).
			Press("a")

		t.ExpectPopup().Prompt().
			Title(Equals("Enter a branch name")).
			Type("three").
			SuggestionLines(Contains("branch-three")).
			ConfirmFirstSuggestion()

		t.Views().Branches().
			Lines(
				Contains("branch-three"),
				Contains("branch-four").IsSelected(),
				Contains("branch-two"),
				Contains("branch-one"),
			)
	},
})

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL