/
main.go
80 lines (66 loc) · 1.58 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package main
import (
"bufio"
"io"
"io/ioutil"
"log"
"os"
"text/tabwriter"
"github.com/segmentio/cli"
"github.com/segmentio/cli/human"
"github.com/segmentio/feature"
)
func main() {
log.SetOutput(ioutil.Discard)
cli.Exec(cli.CommandSet{
"benchmark": cli.Command(benchmark),
"create": cli.CommandSet{
"gate": cli.Command(createGate),
"tier": cli.Command(createTier),
},
"delete": cli.CommandSet{
"gate": cli.Command(deleteGate),
"tier": cli.Command(deleteTier),
},
"get": cli.CommandSet{
"gates": cli.Command(getGates),
"tiers": cli.Command(getTiers),
},
"add": cli.Command(add),
"remove": cli.Command(remove),
"describe": cli.CommandSet{
"tier": cli.Command(describeTier),
"collection": cli.Command(describeCollection),
},
"enable": cli.Command(enable),
"disable": cli.Command(disable),
})
}
type commonConfig struct {
Path human.Path `flag:"-p,--path" help:"Path to the directory where the feature database is stored" default:"~/.feature"`
}
func (c *commonConfig) mount(do func(feature.MountPoint) error) error {
p, err := feature.Mount(string(c.Path))
if err != nil {
return err
}
return do(p)
}
type outputConfig struct {
}
func (c *outputConfig) buffered(do func(io.Writer) error) error {
bw := bufio.NewWriter(os.Stdout)
defer bw.Flush()
return do(bw)
}
func (c *outputConfig) table(do func(io.Writer) error) error {
tw := tabwriter.NewWriter(os.Stdout, 0, 8, 2, ' ', 0)
defer tw.Flush()
return do(tw)
}
type family string
type group string
type collection string
type tier string
type gate string
type id string