-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
48 lines (41 loc) · 1.2 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
package main
import (
"flag"
"fmt"
"os"
"runtime"
"github.com/Justintime50/alchemist/v3/src/brew"
"github.com/Justintime50/alchemist/v3/src/choco"
)
// main function that accepts CLI args to invoke different functionality
func main() {
if runtime.GOOS == "windows" {
chocoUpdate := flag.Bool("update", false, "Update your Chocolatey instance.")
chocoBackup := flag.Bool("backup", false, "Backup your Chocolatey instance.")
flag.Parse()
if *chocoUpdate {
choco.Update()
return
} else if *chocoBackup {
choco.Backup()
return
}
fmt.Println("No action taken as no flag was passed.")
os.Exit(1)
} else {
brewUpdate := flag.Bool("update", false, "Update your Homebrew instance.")
brewBackup := flag.Bool("backup", false, "Backup your Homebrew instance.")
force := flag.Bool("force", false, "Forces actions such as backing up even when there are errors.")
greedy := flag.Bool("greedy", false, "Force updates to casks that have auto-update capabilities in their respective UIs.")
flag.Parse()
if *brewUpdate {
brew.Update(*greedy)
return
} else if *brewBackup {
brew.Backup(*force)
return
}
fmt.Println("No action taken as no flag was passed.")
os.Exit(1)
}
}