-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
main.go
59 lines (50 loc) · 1.13 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
package main
import (
"os"
"github.com/fyne-io/fyne-cross/internal/command"
"github.com/fyne-io/fyne-cross/internal/log"
)
func main() {
// Define the command to use
commands := []command.Command{
&command.DarwinSDKExtract{},
command.NewDarwinCommand(),
command.NewLinuxCommand(),
command.NewWindowsCommand(),
command.NewAndroidCommand(),
command.NewIOSCommand(),
command.NewFreeBSD(),
command.NewWebCommand(),
&command.Version{},
}
// display fyne-cross usage if no command is specified
if len(os.Args) == 1 {
command.Usage(commands)
os.Exit(1)
}
// check for valid command
var cmd command.Command
for _, v := range commands {
if os.Args[1] == v.Name() {
cmd = v
break
}
}
// If no valid command is specified display the usage
if cmd == nil {
command.Usage(commands)
os.Exit(1)
}
// Parse the arguments for the command
// It will display the command usage if -help is specified
// and will exit in case of error
err := cmd.Parse(os.Args[2:])
if err != nil {
log.Fatalf("[✗] %s", err)
}
// Finally run the command
err = cmd.Run()
if err != nil {
log.Fatalf("[✗] %s", err)
}
}