-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (33 loc) · 1.04 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
package main
import (
stdlog "log"
"github.com/cartermckinnon/filter-feed/cmd"
"github.com/integrii/flaggy"
)
var log = stdlog.Default()
func main() {
flaggy.SetName("filter-feed")
flaggy.SetDescription("for fetchin' filtered feeds")
flaggy.SetVersion("0.0.0-dev")
var subcommands []cmd.Command
subcommands = append(subcommands, cmd.NewServerCommand())
subcommands = append(subcommands, cmd.NewFetchCommand())
subcommands = append(subcommands, cmd.NewURLCommand())
for _, subcommand := range subcommands {
flaggy.AttachSubcommand(subcommand.GetFlaggySubcommand(), 1) // flaggy positions start at 1
}
flaggy.ShowHelpOnUnexpectedEnable()
flaggy.Parse()
var usedCommand cmd.Command
for _, subcommand := range subcommands {
if subcommand.GetFlaggySubcommand().Used {
usedCommand = subcommand
break
}
}
if usedCommand == nil {
flaggy.ShowHelpAndExit("error: no subcommand specified")
} else if err := usedCommand.Run(); err != nil {
log.Fatalf("error running command=%s: %v", usedCommand.GetFlaggySubcommand().Name, err)
}
}