-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.go
57 lines (48 loc) · 1.29 KB
/
cli.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
package main
import (
"az-func-deploy/config"
"az-func-deploy/deployment"
"az-func-deploy/ui"
"az-func-deploy/util"
"os"
"github.com/rivo/tview"
)
const (
__pageNameSetSelection string = "Select Deployment Set"
__pageNameDeployment string = "Deployment"
)
func main() {
conf := config.ReadConfigOrPanic()
if len(os.Args) > 1 && os.Args[1] == "--cli" {
deployment.DeployFunctions(conf, os.Stdout, true)
} else {
app := tview.NewApplication()
pages := tview.NewPages()
pageDeployment := tview.NewTextView()
pageDeployment.
SetDynamicColors(true).
SetChangedFunc(func() {
app.Draw()
pageDeployment.ScrollToEnd()
})
outputWriter := tview.ANSIWriter(pageDeployment)
pageSelection := ui.NewSetSelectionLayout(conf, func() {
pages.SwitchToPage(__pageNameDeployment)
pages.SetTitle(__pageNameDeployment)
go deployment.DeployFunctions(conf, outputWriter, false)
})
pages.SetBorder(true).
SetTitle(__pageNameSetSelection)
pages.AddPage(__pageNameSetSelection, pageSelection, true, true)
pages.AddPage(__pageNameDeployment, pageDeployment, true, false)
if err := app.SetRoot(pages, true).Run(); err != nil {
panic(err)
}
util.ExecuteKill()
for _, file := range util.GetCleanupFiles() {
if util.ExistsFile(file) {
os.Remove(file)
}
}
}
}