-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (35 loc) · 777 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"errors"
"fmt"
"log"
"os"
"github.com/nu50218/impls/command"
"github.com/nu50218/impls/command/help"
"github.com/nu50218/impls/command/iface"
"github.com/nu50218/impls/command/types"
"github.com/nu50218/impls/command/vars"
)
func run(args []string) error {
if len(args) < 1 {
return errors.New("you must pass a subcommand")
}
subCommand := args[0]
subCommands := []command.Command{
iface.Command,
types.Command,
vars.Command,
}
subCommands = append(subCommands, help.New(subCommands...))
for _, sc := range subCommands {
if sc.Name() == subCommand {
return sc.Run(args[1:])
}
}
return fmt.Errorf("Unknown subcommand: %s", subCommand)
}
func main() {
if err := run(os.Args[1:]); err != nil {
log.Fatal(err)
}
}