track the application name used by bash autocomplete
This commit is contained in:
parent
2d811f1796
commit
0c004de022
13
bash.go
13
bash.go
|
@ -25,9 +25,10 @@ type ArgsBash struct {
|
||||||
var myBash *BashAuto
|
var myBash *BashAuto
|
||||||
|
|
||||||
type BashAuto struct {
|
type BashAuto struct {
|
||||||
id int // should be unique
|
id int // should be unique
|
||||||
hidden bool // don't update the toolkits when it's hidden
|
hidden bool // don't update the toolkits when it's hidden
|
||||||
Auto func([]string)
|
Auto func([]string)
|
||||||
|
appName string // a good way to track the name of the binary ?
|
||||||
}
|
}
|
||||||
|
|
||||||
func dumpjunk() {
|
func dumpjunk() {
|
||||||
|
@ -51,11 +52,17 @@ func Bash(argname string, autocomplete func([]string)) *BashAuto {
|
||||||
arg.Register(&argBash)
|
arg.Register(&argBash)
|
||||||
|
|
||||||
myBash = new(BashAuto)
|
myBash = new(BashAuto)
|
||||||
|
myBash.appName = argname
|
||||||
|
|
||||||
// parse go.Arg here?
|
// parse go.Arg here?
|
||||||
return myBash
|
return myBash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns the name of the executable registered for shell autocomplete
|
||||||
|
func AppName() string {
|
||||||
|
return myBash.appName
|
||||||
|
}
|
||||||
|
|
||||||
// makes a bash autocomplete file for your command
|
// makes a bash autocomplete file for your command
|
||||||
func doBash(argname string) {
|
func doBash(argname string) {
|
||||||
fmt.Println(makeBashCompletionText(argname))
|
fmt.Println(makeBashCompletionText(argname))
|
||||||
|
|
Loading…
Reference in New Issue