Add plural forms for less verbose declarations

This commit is contained in:
Eyal Posener 2017-05-05 18:06:31 +03:00
parent bc26c054b7
commit 6311b602ab
2 changed files with 30 additions and 19 deletions

View File

@ -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

View File

@ -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{
"-run": complete.FlagUnknownFollow, test = complete.Command{
"-count": complete.FlagUnknownFollow, Flags: complete.Flags{
}, "-run": complete.FlagUnknownFollow,
"-count": complete.FlagUnknownFollow,
}, },
}, }
Flags: map[string]complete.FlagOptions{
"-h": complete.FlagNoFollow, gogo = complete.Command{
}, Sub: complete.Commands{
}) "build": build,
"test": test,
},
Flags: complete.Flags{
"-h": complete.FlagNoFollow,
},
}
)
func main() { func main() {
completer.Complete() complete.New(gogo).Complete()
} }