forked from palantir/godel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
amalgomatedformatters.go
44 lines (36 loc) · 923 Bytes
/
amalgomatedformatters.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
44
// generated by amalgomate; DO NOT EDIT
package amalgomatedformatters
import (
"fmt"
"sort"
gofmt "github.com/palantir/godel/apps/gonform/generated_src/internal/cmd/gofmt"
ptimports "github.com/palantir/godel/apps/gonform/generated_src/internal/github.com/palantir/checks/ptimports/main/ptimports"
)
var programs = map[string]func(){"gofmt": func() {
gofmt.AmalgomatedMain()
}, "ptimports": func() {
ptimports.AmalgomatedMain()
},
}
func Instance() Amalgomated {
return &amalgomated{}
}
type Amalgomated interface {
Run(cmd string)
Cmds() []string
}
type amalgomated struct{}
func (a *amalgomated) Run(cmd string) {
if _, ok := programs[cmd]; !ok {
panic(fmt.Sprintf("Unknown command: \"%v\". Valid values: %v", cmd, a.Cmds()))
}
programs[cmd]()
}
func (a *amalgomated) Cmds() []string {
var cmds []string
for key := range programs {
cmds = append(cmds, key)
}
sort.Strings(cmds)
return cmds
}