-
Notifications
You must be signed in to change notification settings - Fork 2
/
subcommands.go
99 lines (76 loc) · 2.76 KB
/
subcommands.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package main
import "github.com/ndaba1/gommander"
func main() {
// DISCLAIMER: NOT A FULL CLONE OF DOCKER FUNCTIONALITY, JUST A SIMPLE EXAMPLE
// Run this example with --help to see how it is printed out
app := gommander.App().
Version("0.1.0").
Help("A simple docker example").
Name("docker")
image := app.SubCommand("image").
Alias("i").
Help("Manage images").
AddToGroup("Management Commands")
// docker image subcommands
image.SubCommand("ls").
Help("List images").
Flag("-a --all", "Show all images (default hides intermediate images)").
Flag("--digests", "Show all images (default hides intermediate images)").
Option("-f --filter filter", "Filter output based on conditions provided").
Alias("l")
image.SubCommand("build").
Alias("b").
Help("Build an image from a Dockerfile").
Argument("<path>", "The path to the build context").
Flag("--add-host list", "Add a custom host-to-IP mapping (host:ip)").
Option(" -f --file <string>", "Name of the Dockerfile (Default is 'PATH/Dockerfile')")
container := app.SubCommand("container").
Alias("cont").
Help("Manage containers").
AddToGroup("Management Commands")
// docker container subcommands
container.SubCommand("prune").
Help("Remove all stopped containers").
Flag("-f --force", "Do not prompt for confirmation")
container.SubCommand("start").
Help("Start one or more stopped containers").
Flag("-i --interactive", "Attach container's STDIN")
container.SubCommand("create").
Help("Create a new container").
Flag("--add-host list", "Add a custom host-to-IP mapping (host:ip)")
// Other app subcommands
app.SubCommand("network").
Alias("n").
Help("Manage networks").
AddToGroup("Management Commands")
app.SubCommand("builder").
Help("Manage builds").
AddToGroup("Management Commands")
app.SubCommand("compose").
Help("Docker Compose (Docker Inc., v2.4.1)").
AddToGroup("Management Commands")
// A new set of command groups
attach := app.
SubCommand("attach").
Help("Attach local standard input, output, and error streams to a running container")
build := app.
SubCommand("build").
Help("Build an image from a Dockerfile")
commit := app.
SubCommand("commit").
Help("Create a new image from a container's changes")
cp := app.
SubCommand("cp").
Help("Copy files/folders between a container and the local filesystem")
create := app.
SubCommand("create").
Help("Create a new container")
diff := app.
SubCommand("diff").
Help("Inspect changes to files or directories on a container's filesystem")
// An alternative way for creating subcommand groups
app.SubCommandGroup("Commands", []*gommander.Command{attach, build, commit, cp, create, diff})
// The real docker-cli has no color printing
app.Set(gommander.DisableColor, true)
app.Parse()
}