Add plural forms for less verbose declarations
This commit is contained in:
parent
bc26c054b7
commit
6311b602ab
|
@ -1,8 +1,12 @@
|
||||||
package complete
|
package complete
|
||||||
|
|
||||||
|
type Commands map[string]Command
|
||||||
|
|
||||||
|
type Flags map[string]FlagOptions
|
||||||
|
|
||||||
type Command struct {
|
type Command struct {
|
||||||
Sub map[string]Command
|
Sub Commands
|
||||||
Flags map[string]FlagOptions
|
Flags Flags
|
||||||
}
|
}
|
||||||
|
|
||||||
// options returns all available complete options for the given command
|
// options returns all available complete options for the given command
|
||||||
|
|
|
@ -4,25 +4,32 @@ import (
|
||||||
"github.com/posener/complete"
|
"github.com/posener/complete"
|
||||||
)
|
)
|
||||||
|
|
||||||
var completer = complete.New(complete.Command{
|
var (
|
||||||
Sub: map[string]complete.Command{
|
build = complete.Command{
|
||||||
"build": {
|
Flags: complete.Flags{
|
||||||
Flags: map[string]complete.FlagOptions {
|
|
||||||
"-o": complete.FlagUnknownFollow,
|
"-o": complete.FlagUnknownFollow,
|
||||||
}, "-i": complete.FlagNoFollow,
|
"-i": complete.FlagNoFollow,
|
||||||
},
|
},
|
||||||
"test": {
|
}
|
||||||
Flags: map[string]complete.FlagOptions{
|
|
||||||
|
test = complete.Command{
|
||||||
|
Flags: complete.Flags{
|
||||||
"-run": complete.FlagUnknownFollow,
|
"-run": complete.FlagUnknownFollow,
|
||||||
"-count": complete.FlagUnknownFollow,
|
"-count": complete.FlagUnknownFollow,
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
gogo = complete.Command{
|
||||||
|
Sub: complete.Commands{
|
||||||
|
"build": build,
|
||||||
|
"test": test,
|
||||||
},
|
},
|
||||||
},
|
Flags: complete.Flags{
|
||||||
Flags: map[string]complete.FlagOptions{
|
|
||||||
"-h": complete.FlagNoFollow,
|
"-h": complete.FlagNoFollow,
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
completer.Complete()
|
complete.New(gogo).Complete()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue