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
|
diff --git a/cmd/source.go b/cmd/source.go
index 1a5f820279092622d0ae16f29eb41e8269d1ce3a..70f2adb2f1760bb1dba6792d5e43b7eb46d2ea7f 100644
--- a/cmd/source.go
+++ b/cmd/source.go
@@ -1,6 +1,7 @@
package cmd
import (
+ "encoding/json"
"fmt"
"os"
"text/tabwriter"
@@ -28,7 +29,13 @@ SourceList = &cli.Command{
Name: "list",
Usage: "List available sources",
Description: "List all available sources in the registry",
- Action: runSourceList,
+ Flags: []cli.Flag{
+ &cli.BoolFlag{
+ Name: "json",
+ Usage: "JSON format",
+ },
+ },
+ Action: runSourceList,
}
SourceAdd = &cli.Command{
@@ -48,10 +55,14 @@ Action: runSourceRemove,
}
)
-func runSourceList(_ *cli.Context) error {
+func runSourceList(ctx *cli.Context) error {
reg, err := registry.Open(registryFlag)
if err != nil {
return err
+ }
+
+ if ctx.Bool("json") {
+ return json.NewEncoder(os.Stdout).Encode(reg.Sources)
}
wr := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0)
|