Refactoring names from bash to shell
The refactoring is required since completion is also supported for zsh shell. Refactoring details: - flag generate-bash-completion -> generate-completion - var EnableBashCompletion -> EnableShellCompletion - var BashComplete -> ShellComplete - var BashCompletionFlag -> GenerateCompletionFlag - type BashCompleteFunc -> ShellCompleteFunc
This commit is contained in:
20
app_test.go
20
app_test.go
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
type opCounts struct {
|
||||
Total, BashComplete, OnUsageError, Before, CommandNotFound, Action, After, SubCommand int
|
||||
Total, ShellComplete, OnUsageError, Before, CommandNotFound, Action, After, SubCommand int
|
||||
}
|
||||
|
||||
func ExampleApp_Run() {
|
||||
@@ -112,13 +112,13 @@ func ExampleApp_Run_help() {
|
||||
// This is how we describe describeit the function
|
||||
}
|
||||
|
||||
func ExampleApp_Run_bashComplete() {
|
||||
func ExampleApp_Run_shellComplete() {
|
||||
// set args for examples sake
|
||||
os.Args = []string{"greet", "--generate-bash-completion"}
|
||||
os.Args = []string{"greet", "--generate-completion"}
|
||||
|
||||
app := &App{
|
||||
Name: "greet",
|
||||
EnableBashCompletion: true,
|
||||
EnableShellCompletion: true,
|
||||
Commands: []*Command{
|
||||
{
|
||||
Name: "describeit",
|
||||
@@ -132,7 +132,7 @@ func ExampleApp_Run_bashComplete() {
|
||||
}, {
|
||||
Name: "next",
|
||||
Usage: "next example",
|
||||
Description: "more stuff to see when generating bash completion",
|
||||
Description: "more stuff to see when generating shell completion",
|
||||
Action: func(c *Context) error {
|
||||
fmt.Printf("the next example")
|
||||
return nil
|
||||
@@ -735,10 +735,10 @@ func TestApp_OrderOfOperations(t *testing.T) {
|
||||
resetCounts := func() { counts = &opCounts{} }
|
||||
|
||||
app := &App{
|
||||
EnableBashCompletion: true,
|
||||
BashComplete: func(c *Context) {
|
||||
EnableShellCompletion: true,
|
||||
ShellComplete: func(c *Context) {
|
||||
counts.Total++
|
||||
counts.BashComplete = counts.Total
|
||||
counts.ShellComplete = counts.Total
|
||||
},
|
||||
OnUsageError: func(c *Context, err error, isSubcommand bool) error {
|
||||
counts.Total++
|
||||
@@ -801,8 +801,8 @@ func TestApp_OrderOfOperations(t *testing.T) {
|
||||
|
||||
resetCounts()
|
||||
|
||||
_ = app.Run([]string{"command", "--generate-bash-completion"})
|
||||
expect(t, counts.BashComplete, 1)
|
||||
_ = app.Run([]string{"command", "--generate-completion"})
|
||||
expect(t, counts.ShellComplete, 1)
|
||||
expect(t, counts.Total, 1)
|
||||
|
||||
resetCounts()
|
||||
|
Reference in New Issue
Block a user