@ -35,7 +35,7 @@ applications in an expressive way.
* [Subcommands ](#subcommands )
* [Subcommands categories ](#subcommands-categories )
* [Exit code ](#exit-code )
* [Bash Completion](#bash -completion)
* [Shell Completion](#shell -completion)
+ [Enabling ](#enabling )
+ [Distribution ](#distribution )
+ [Customization ](#customization )
@ -740,15 +740,15 @@ func main() {
}
```
### Bash Completion
### Shell Completion
You can enable completion commands by setting the `Enable Bash Completion`
You can enable completion commands by setting the `Enable Shell Completion`
flag on the `App` object. By default, this setting will only auto-complete to
show an app's subcommands, but you can write your own completion methods for
the App or its subcommands.
<!-- {
"args": ["complete", "- - generate- bash- completion"],
"args": ["complete", "- - generate- completion"],
"output": "laundry"
} -->
``` go
@ -765,7 +765,7 @@ func main() {
tasks := []string{"cook", "clean", "laundry", "eat", "sleep", "code"}
app := & cli.App{
EnableBash Completion: true,
EnableShell Completion: true,
Commands: []*cli.Command{
{
Name: "complete",
@ -775,7 +775,7 @@ func main() {
fmt.Println("completed task: ", c.Args().First())
return nil
},
Bash Complete: func(c *cli.Context) {
Shell Complete: func(c *cli.Context) {
// This will complete if no args are passed
if c.NArg() > 0 {
return
@ -794,7 +794,7 @@ func main() {
#### Enabling
You can generate bash or zsh completion code by using the flag `--init-completion bash` or `--init-completion ba sh`.
You can generate bash or zsh completion code by using the flag `--init-completion bash` or `--init-completion z sh`.
To setup for bash:
@ -825,8 +825,8 @@ to the name of their program (as above).
#### Customization
The default ba sh completion flag (`--generate-bash -completion`) is defined as
`cli. Bash CompletionFlag`, and may be redefined if desired, e.g.:
The default shell completion flag (`--generate-completion`) is defined as
`cli. Generate CompletionFlag`, and may be redefined if desired, e.g.:
<!-- {
"args": ["- - compgen"],
@ -842,13 +842,13 @@ import (
)
func main() {
cli.Bash CompletionFlag = & cli.BoolFlag{
cli.Generate CompletionFlag = & cli.BoolFlag{
Name: "compgen",
Hidden: true,
}
app := & cli.App{
EnableBash Completion: true,
EnableShell Completion: true,
Commands: []*cli.Command{
{
Name: "wat",
@ -1058,7 +1058,7 @@ func init() {
cli.SubcommandHelpTemplate += "\nor something\n"
cli.HelpFlag = & cli.BoolFlag{Name: "halp"}
cli.Bash CompletionFlag = & cli.BoolFlag{Name: "compgen", Hidden: true}
cli.Generate CompletionFlag = & cli.BoolFlag{Name: "compgen", Hidden: true}
cli.VersionFlag = & cli.BoolFlag{Name: "print-version", Aliases: []string{"V"}}
cli.HelpPrinter = func(w io.Writer, templ string, data interface{}) {
@ -1138,7 +1138,7 @@ func main() {
HideHelp: false,
Hidden: false,
HelpName: "doo!",
Bash Complete: func(c *cli.Context) {
Shell Complete: func(c *cli.Context) {
fmt.Fprintf(c.App.Writer, "--better\n")
},
Before: func(c *cli.Context) error {
@ -1181,10 +1181,10 @@ func main() {
& cli.UintFlag{Name: "age"},
& cli.Uint64Flag{Name: "bigage"},
},
EnableBash Completion: true,
EnableShell Completion: true,
HideHelp: false,
HideVersion: false,
Bash Complete: func(c *cli.Context) {
Shell Complete: func(c *cli.Context) {
fmt.Fprintf(c.App.Writer, "lipstick\nkiss\nme\nlipstick\nringo\n")
},
Before: func(c *cli.Context) error {