-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgorbit.go
More file actions
68 lines (59 loc) · 1.28 KB
/
gorbit.go
File metadata and controls
68 lines (59 loc) · 1.28 KB
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
package main
import (
"C"
"fmt"
"os"
"github.com/fatih/color"
"github.com/filiptc/gorbit/config"
"github.com/filiptc/gorbit/control"
"github.com/filiptc/gorbit/formats"
"github.com/filiptc/gorbit/webcam"
"github.com/filiptc/gorbit/webserver"
"github.com/jessevdk/go-flags"
)
func main() {
var err error
config := config.NewConfig()
config.Font, err = Asset("assets/luximr.ttf")
config.Index, err = Asset("assets/index.html")
if err != nil {
panic(err)
}
go webcam.ProcessCommands()
parser := createCommandParser(config)
if _, err = parser.Parse(); err != nil {
fmt.Println(color.RedString(err.Error()))
os.Exit(1)
}
}
func createCommandParser(config *config.Config) *flags.Parser {
parser := flags.NewParser(nil, flags.Default)
_, err := parser.AddCommand(
"control",
"control camera",
"Control camera via commands like pan, tilt, reset, etc.",
control.NewControlCommand(),
)
if err != nil {
panic(err)
}
_, err = parser.AddCommand(
"serve",
"lauch webserver",
"View, pan and tilt webcam via webserver",
webserver.NewWebserverCommand(config),
)
if err != nil {
panic(err)
}
_, err = parser.AddCommand(
"formats",
"view formats",
"View webcam formats",
formats.NewFormatsCommand(config),
)
if err != nil {
panic(err)
}
return parser
}