diff options
| author | hilimd <68371223+hilimd@users.noreply.github.com> | 2020-09-22 09:33:25 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-22 09:33:25 +0800 |
| commit | 082500151a85f4d59a9f779174bcb3043b723272 (patch) | |
| tree | f423c694d8f6af15d59ab1c4401d3e80fac876c3 /weed/shell/command_collection_delete.go | |
| parent | f71f7fcf99ba6d64bfa49fd7411e06bdc2b9d591 (diff) | |
| parent | 9cdbfc1a4987bdb46f16ae37624ed69ef66778a9 (diff) | |
| download | seaweedfs-082500151a85f4d59a9f779174bcb3043b723272.tar.xz seaweedfs-082500151a85f4d59a9f779174bcb3043b723272.zip | |
Merge pull request #16 from chrislusf/master
sync
Diffstat (limited to 'weed/shell/command_collection_delete.go')
| -rw-r--r-- | weed/shell/command_collection_delete.go | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/weed/shell/command_collection_delete.go b/weed/shell/command_collection_delete.go index 4b3d7f0be..28b9cebbd 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 }) @@ -44,7 +55,7 @@ func (c *commandCollectionDelete) Do(args []string, commandEnv *CommandEnv, writ return } - fmt.Fprintf(writer, "collection %s is deleted.\n", collectionName) + fmt.Fprintf(writer, "collection %s is deleted.\n", *collectionName) return nil } |
