aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_collection_list.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-05-05 22:21:28 -0700
committerChris Lu <chris.lu@gmail.com>2019-05-05 22:21:28 -0700
commitf08bbb72de4dcc9834004a505c12c8cdd1bf920c (patch)
treeae9ac95e135ccd656f0a39207a4d14f74cd01f46 /weed/shell/command_collection_list.go
parent0df6346611910226d5e0a1b42b3c9a8ab687997a (diff)
downloadseaweedfs-f08bbb72de4dcc9834004a505c12c8cdd1bf920c.tar.xz
seaweedfs-f08bbb72de4dcc9834004a505c12c8cdd1bf920c.zip
refactoring
Diffstat (limited to 'weed/shell/command_collection_list.go')
-rw-r--r--weed/shell/command_collection_list.go27
1 files changed, 19 insertions, 8 deletions
diff --git a/weed/shell/command_collection_list.go b/weed/shell/command_collection_list.go
index cc16fd291..008a83e14 100644
--- a/weed/shell/command_collection_list.go
+++ b/weed/shell/command_collection_list.go
@@ -24,22 +24,33 @@ func (c *commandCollectionList) Help() string {
func (c *commandCollectionList) Do(args []string, commandEnv *commandEnv, writer io.Writer) (err error) {
+ collections, err := ListCollectionNames(commandEnv)
+
+ if err != nil {
+ return err
+ }
+
+ for _, c := range collections {
+ fmt.Fprintf(writer, "collection:\"%s\"\n", c)
+ }
+
+ fmt.Fprintf(writer, "Total %d collections.\n", len(collections))
+
+ return nil
+}
+
+func ListCollectionNames(commandEnv *commandEnv) (collections []string, err error) {
var resp *master_pb.CollectionListResponse
ctx := context.Background()
err = commandEnv.masterClient.WithClient(ctx, func(client master_pb.SeaweedClient) error {
resp, err = client.CollectionList(ctx, &master_pb.CollectionListRequest{})
return err
})
-
if err != nil {
- return err
+ return
}
-
for _, c := range resp.Collections {
- fmt.Fprintf(writer, "collection:\"%s\"\n", c.GetName())
+ collections = append(collections, c.Name)
}
-
- fmt.Fprintf(writer, "Total %d collections.\n", len(resp.Collections))
-
- return nil
+ return
}