Skip to content

Commit 5a71968

Browse files
committed
change files architecture
1 parent 657bdb5 commit 5a71968

6 files changed

Lines changed: 692 additions & 699 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dtop

docker.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package main
2+
3+
import (
4+
"log"
5+
"os"
6+
"strings"
7+
8+
"github.com/fsouza/go-dockerclient"
9+
)
10+
11+
func initClient() *docker.Client {
12+
var client *docker.Client
13+
var e error
14+
15+
certs := os.Getenv(*fCerts)
16+
host := os.Getenv(*fHost)
17+
if host == "" {
18+
host = "unix:///var/run/docker.sock"
19+
}
20+
21+
if strings.HasPrefix(host, "unix") {
22+
client, e = docker.NewClient(host)
23+
if e != nil {
24+
log.Fatal(e)
25+
}
26+
} else {
27+
client, e = docker.NewTLSClient(host, certs+"/cert.pem", certs+"/key.pem", "")
28+
if e != nil {
29+
log.Fatal(e)
30+
}
31+
}
32+
33+
return client
34+
}

help.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package main
2+
3+
type ItemPair struct {
4+
Com string
5+
Def string
6+
}
7+
8+
type Page struct {
9+
Header string
10+
Info string
11+
Body []ItemPair
12+
Footer string
13+
}
14+
15+
var help = Page{
16+
Header: `
17+
Help of "pot" command:
18+
`,
19+
Info: `
20+
`,
21+
Body: []ItemPair{
22+
{"<arrow up>", "scroll up"},
23+
{"<arrow down>", "scroll down"},
24+
{"<space>", "select/unselect container"},
25+
{"u", "unselect all containers"},
26+
{"q", "quit"},
27+
{"h", "prints this help"},
28+
{"a", "show/hide processes on selected containers"},
29+
{"A", "show/hide processes on all containers"},
30+
{"k", "kill selected containers"},
31+
{"s", "start selected containers"},
32+
{"S", "stop selected containers"},
33+
{"r", "remove selected containers"},
34+
{"i", "view information about current container"},
35+
{"p", "pause selected containers"},
36+
{"P", "unpause selected containers"},
37+
{"1", "sort by name"},
38+
{"2", "sort by image"},
39+
{"3", "sort by id"},
40+
{"4", "sort by command"},
41+
{"5", "sort by uptime"},
42+
{"6", "sort by status"},
43+
{"7", "sort by %CPU"},
44+
{"8", "sort by %RAM"},
45+
{"I", "revert current sort"},
46+
},
47+
Footer: `
48+
Press 'h' to return.
49+
`,
50+
}

0 commit comments

Comments
 (0)