-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
52 lines (43 loc) · 1023 Bytes
/
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
package main
import (
"context"
"fmt"
"os"
"runtime"
"github.com/ernesto27/dcli/docker"
"github.com/ernesto27/dcli/models"
"github.com/ernesto27/dcli/utils"
"github.com/shirou/gopsutil/mem"
tea "github.com/charmbracelet/bubbletea"
)
func main() {
ctx := context.Background()
msgError := "Error connecting to docker daemon, please check if docker is installed and running..."
dockerClient, err := docker.New(ctx)
if err != nil {
fmt.Println(msgError)
os.Exit(1)
}
version, err := dockerClient.ServerVersion()
if err != nil {
fmt.Println(msgError)
os.Exit(1)
}
dockerClient.Events()
// set images, volumes for count view
dockerClient.ImageList()
dockerClient.VolumeList()
ram := ""
v, err := mem.VirtualMemory()
if err == nil {
ram = utils.FormatSize(int64(v.Total))
}
m := models.NewModel(dockerClient, version, runtime.NumCPU(), ram)
if _, err := tea.NewProgram(
m,
tea.WithAltScreen(),
).Run(); err != nil {
fmt.Println("Error running program:", err)
os.Exit(1)
}
}