/
list.go
72 lines (61 loc) · 1.68 KB
/
list.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
package cli
import (
"fmt"
"net/http"
"github.com/aquaproj/aqua/v2/pkg/config"
"github.com/aquaproj/aqua/v2/pkg/controller"
"github.com/urfave/cli/v2"
)
func (r *Runner) newListCommand() *cli.Command {
return &cli.Command{
Name: "list",
Usage: "List packages in Registries",
Action: r.listAction,
Description: `Output the list of packages in registries.
The output format is <registry name>,<package name>
e.g.
$ aqua list
standard,99designs/aws-vault
standard,abiosoft/colima
standard,abs-lang/abs
...
If the option -installed is set, the command lists only installed packages.
$ aqua list -installed
standard,golangci/golangci-lint,v1.56.2
standard,goreleaser/goreleaser,v1.24.0
...
By default, the command doesn't list global configuration packages.
If you want to list global configuration packages too, please set the option -a.
$ aqua list -installed -a
`,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "installed",
Usage: "List installed packages",
},
&cli.BoolFlag{
Name: "all",
Aliases: []string{"a"},
Usage: "List global configuration packages too",
},
},
}
}
func (r *Runner) listAction(c *cli.Context) error {
tracer, err := startTrace(c.String("trace"))
if err != nil {
return err
}
defer tracer.Stop()
cpuProfiler, err := startCPUProfile(c.String("cpu-profile"))
if err != nil {
return err
}
defer cpuProfiler.Stop()
param := &config.Param{}
if err := r.setParam(c, "list", param); err != nil {
return fmt.Errorf("parse the command line arguments: %w", err)
}
ctrl := controller.InitializeListCommandController(c.Context, param, http.DefaultClient, r.Runtime)
return ctrl.List(c.Context, param, r.LogE) //nolint:wrapcheck
}