forked from terrablue/devdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmds.go
More file actions
71 lines (60 loc) · 1.36 KB
/
Copy pathcmds.go
File metadata and controls
71 lines (60 loc) · 1.36 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"context"
"fmt"
"os"
)
func cmdX(args []string) {
if len(args) < 1 {
fmt.Fprintln(os.Stderr, "usage: devdb x <db>[@version] [--name=<name>]")
os.Exit(1)
}
cfg := parseRunArgs(args)
profile, ok := profiles[cfg.db]
if !ok {
fmt.Fprintf(os.Stderr, "unknown db: %s\n", cfg.db)
os.Exit(1)
}
cli, err := newClient()
if err != nil {
fmt.Fprintf(os.Stderr, "could not connect to container runtime: %s\n", err)
os.Exit(1)
}
defer cli.Close()
ctx := context.Background()
if err := runContainer(ctx, cli, cfg, profile); err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err)
os.Exit(1)
}
}
func cmdLs() {
cli, err := newClient()
if err != nil {
fmt.Fprintf(os.Stderr, "could not connect to container runtime: %s\n", err)
os.Exit(1)
}
defer cli.Close()
ctx := context.Background()
if err := listContainers(ctx, cli); err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err)
os.Exit(1)
}
}
func cmdRm(args []string) {
if len(args) < 1 {
fmt.Fprintln(os.Stderr, "usage: devdb rm <name>")
os.Exit(1)
}
name := args[0]
cli, err := newClient()
if err != nil {
fmt.Fprintf(os.Stderr, "could not connect to container runtime: %s\n", err)
os.Exit(1)
}
defer cli.Close()
ctx := context.Background()
if err := killExisting(ctx, cli, name, 0); err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err)
os.Exit(1)
}
}