readme: Update according to go doc (#86)
* Update readme according to go doc
This commit is contained in:
parent
eb60014a10
commit
af07aa5181
35
README.md
35
README.md
|
@ -12,31 +12,33 @@ Writing bash completion scripts is a hard work. This package provides an easy wa
|
||||||
to create bash completion scripts for any command, and also an easy way to install/uninstall
|
to create bash completion scripts for any command, and also an easy way to install/uninstall
|
||||||
the completion of the command.
|
the completion of the command.
|
||||||
|
|
||||||
## go command bash completion
|
#### Go Command Bash Completion
|
||||||
|
|
||||||
In [gocomplete](./cmd/gocomplete) there is an example for bash completion for the `go` command line.
|
In [./cmd/gocomplete](./cmd/gocomplete) there is an example for bash completion for the `go` command line.
|
||||||
|
|
||||||
This is an example that uses the `complete` package on the `go` command - the `complete` package
|
This is an example that uses the `complete` package on the `go` command - the `complete` package
|
||||||
can also be used to implement any completions, see [Usage](#usage).
|
can also be used to implement any completions, see #usage.
|
||||||
|
|
||||||
### Install
|
#### Install
|
||||||
|
|
||||||
1. Type in your shell:
|
1. Type in your shell:
|
||||||
|
|
||||||
go get -u github.com/posener/complete/gocomplete
|
```go
|
||||||
gocomplete -install
|
go get -u github.com/posener/complete/gocomplete
|
||||||
|
gocomplete -install
|
||||||
|
```
|
||||||
|
|
||||||
2. Restart your shell
|
2. Restart your shell
|
||||||
|
|
||||||
Uninstall by `gocomplete -uninstall`
|
Uninstall by `gocomplete -uninstall`
|
||||||
|
|
||||||
### Features
|
#### Features
|
||||||
|
|
||||||
- Complete `go` command, including sub commands and all flags.
|
- Complete `go` command, including sub commands and all flags.
|
||||||
- Complete packages names or `.go` files when necessary.
|
- Complete packages names or `.go` files when necessary.
|
||||||
- Complete test names after `-run` flag.
|
- Complete test names after `-run` flag.
|
||||||
|
|
||||||
## complete package
|
#### Complete package
|
||||||
|
|
||||||
Supported shells:
|
Supported shells:
|
||||||
|
|
||||||
|
@ -44,7 +46,7 @@ Supported shells:
|
||||||
- [x] zsh
|
- [x] zsh
|
||||||
- [x] fish
|
- [x] fish
|
||||||
|
|
||||||
### Usage
|
#### Usage
|
||||||
|
|
||||||
Assuming you have program called `run` and you want to have bash completion
|
Assuming you have program called `run` and you want to have bash completion
|
||||||
for it, meaning, if you type `run` then space, then press the `Tab` key,
|
for it, meaning, if you type `run` then space, then press the `Tab` key,
|
||||||
|
@ -58,9 +60,10 @@ options for `run`.
|
||||||
|
|
||||||
So here it is:
|
So here it is:
|
||||||
|
|
||||||
import "github.com/posener/complete"
|
```go
|
||||||
|
import "github.com/posener/complete"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// create a Command object, that represents the command we want
|
// create a Command object, that represents the command we want
|
||||||
// to complete.
|
// to complete.
|
||||||
|
@ -105,14 +108,14 @@ So here it is:
|
||||||
// this triggers the autocompletion when needed.
|
// this triggers the autocompletion when needed.
|
||||||
// name must be exactly as the binary that we want to complete.
|
// name must be exactly as the binary that we want to complete.
|
||||||
complete.New("run", run).Run()
|
complete.New("run", run).Run()
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Self completing program
|
#### Self completing program
|
||||||
|
|
||||||
In case that the program that we want to complete is written in go we
|
In case that the program that we want to complete is written in go we
|
||||||
can make it self completing.
|
can make it self completing.
|
||||||
|
Here is an example: [./example/self/main.go](./example/self/main.go) .
|
||||||
Here is an [example](./example/self/main.go)
|
|
||||||
|
|
||||||
## Sub Packages
|
## Sub Packages
|
||||||
|
|
||||||
|
@ -120,6 +123,6 @@ Here is an [example](./example/self/main.go)
|
||||||
|
|
||||||
* [gocomplete](./gocomplete): Package main is complete tool for the go command line
|
* [gocomplete](./gocomplete): Package main is complete tool for the go command line
|
||||||
|
|
||||||
* [match](./match)
|
* [match](./match): Package match contains matchers that decide if to apply completion.
|
||||||
|
|
||||||
Created by [goreadme](https://github.com/apps/goreadme)
|
Created by [goreadme](https://github.com/apps/goreadme)
|
||||||
|
|
Loading…
Reference in New Issue