-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrmi.go
49 lines (43 loc) · 976 Bytes
/
rmi.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
package main
import (
"fmt"
"github.com/olekukonko/tablewriter"
_ "github.com/olekukonko/tablewriter"
"github.com/urfave/cli/v2"
"os"
"strings"
)
func rmi(c *cli.Context) error {
force, filters := c.Bool("force"), c.Args().Slice()
if !force {
images, remain, errs := n.Images(filters...)
if len(remain) > 0 {
return e1("unknown filters: " + strings.Join(remain, ", "))
}
if len(errs) > 0 {
return e(errs)
}
fmt.Println("These will be the images that are removed: ")
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"NAME", "ID"})
for _, v := range images {
table.Append([]string{v.Name, v.Id})
}
table.Render()
fmt.Print("Are you sure you want to continue? [y/N]: ")
var input string
_, err := fmt.Scanln(&input)
if err != nil {
return ee(err)
}
if input == "y" || input == "Y" {
} else {
return nil
}
}
err := n.RemoveImage(filters...)
if len(err) > 0 {
return e(err)
}
return nil
}