aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-09-20 08:46:16 -0700
committerChris Lu <chris.lu@gmail.com>2020-09-20 08:46:16 -0700
commit56094541c8279b34e807aa4fefd2de6a477297de (patch)
tree58c4dff84a92d555ac781f792172a2e076c4dcf9
parent9cac9c40010443cc405e39230e594df19ee08b34 (diff)
downloadseaweedfs-56094541c8279b34e807aa4fefd2de6a477297de.tar.xz
seaweedfs-56094541c8279b34e807aa4fefd2de6a477297de.zip
shell: adjust command option for collection.delete
-rw-r--r--weed/shell/command_collection_delete.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/weed/shell/command_collection_delete.go b/weed/shell/command_collection_delete.go
index 4b3d7f0be..56eaba576 100644
--- a/weed/shell/command_collection_delete.go
+++ b/weed/shell/command_collection_delete.go
@@ -2,6 +2,7 @@ package shell
import (
"context"
+ "flag"
"fmt"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
"io"
@@ -21,22 +22,32 @@ func (c *commandCollectionDelete) Name() string {
func (c *commandCollectionDelete) Help() string {
return `delete specified collection
- collection.delete <collection_name>
+ collection.delete -collectin <collection_name> -force
`
}
func (c *commandCollectionDelete) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
- if len(args) == 0 {
+ if err = commandEnv.confirmIsLocked(); err != nil {
+ return
+ }
+
+ colDeleteCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
+ collectionName := colDeleteCommand.String("collection", "", "collection to delete")
+ applyBalancing := colDeleteCommand.Bool("force", false, "apply the collection")
+ if err = colDeleteCommand.Parse(args); err != nil {
return nil
}
- collectionName := args[0]
+ if !*applyBalancing {
+ fmt.Fprintf(writer, "collection %s will be deleted. Use -force to apply the change.\n", collectionName)
+ return nil
+ }
err = commandEnv.MasterClient.WithClient(func(client master_pb.SeaweedClient) error {
_, err = client.CollectionDelete(context.Background(), &master_pb.CollectionDeleteRequest{
- Name: collectionName,
+ Name: *collectionName,
})
return err
})