forked from mlabouardy/nexus-cli
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.go
More file actions
128 lines (125 loc) · 2.53 KB
/
main.go
File metadata and controls
128 lines (125 loc) · 2.53 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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package main
import (
"fmt"
"os"
"github.com/f9n/nexus-cli/cmd"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Name = "Nexus CLI"
app.Usage = "Manage Docker Private Registry on Nexus"
app.Version = "1.3.0"
app.Authors = []cli.Author{
cli.Author{
Name: "Mohamed Labouardy",
Email: "mohamed@labouardy.com",
},
}
app.Commands = []cli.Command{
{
Name: "configure",
Usage: "Configure Nexus Credentials",
Action: func(c *cli.Context) error {
return cmd.SetNexusCredentials(c)
},
},
{
Name: "image",
Usage: "Manage Docker Images",
Subcommands: []cli.Command{
{
Name: "ls",
Usage: "List all images in repository",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "detail",
},
cli.BoolFlag{
Name: "sort-by-size",
},
},
Action: func(c *cli.Context) error {
return cmd.ListImages(c)
},
},
{
Name: "tags",
Usage: "Display all image tags",
Flags: []cli.Flag{
cli.StringFlag{
Name: "name, n",
Usage: "List tags by image name",
},
},
Action: func(c *cli.Context) error {
return cmd.ListTagsByImage(c)
},
},
{
Name: "info",
Usage: "Show image details",
Flags: []cli.Flag{
cli.StringFlag{
Name: "name, n",
},
cli.StringFlag{
Name: "tag, t",
},
},
Action: func(c *cli.Context) error {
return cmd.ShowImageInfo(c)
},
},
{
Name: "delete",
Usage: "Delete an image",
Flags: []cli.Flag{
cli.StringFlag{
Name: "name, n",
},
cli.StringFlag{
Name: "tag, t",
},
cli.StringFlag{
Name: "keep, k",
},
cli.BoolFlag{
Name: "force, f",
},
},
Action: func(c *cli.Context) error {
return cmd.DeleteImage(c)
},
},
{
Name: "size",
Usage: "Show total size of image including all tags",
Flags: []cli.Flag{
cli.StringFlag{
Name: "name, n",
},
cli.BoolFlag{
Name: "human-readable",
},
},
Action: func(c *cli.Context) error {
return cmd.ShowTotalImageSize(c)
},
},
{
Name: "tree",
Usage: "List all tags of images and in repository",
Flags: []cli.Flag{},
Action: func(c *cli.Context) error {
return cmd.TreeOfAllImages(c)
},
},
},
},
}
app.CommandNotFound = func(c *cli.Context, command string) {
fmt.Fprintf(c.App.Writer, "Wrong command %q !", command)
}
app.Run(os.Args)
}