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_volume_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_volume_delete.go')
| -rw-r--r-- | weed/shell/command_volume_delete.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/weed/shell/command_volume_delete.go b/weed/shell/command_volume_delete.go index c5cc9e277..187caa1a4 100644 --- a/weed/shell/command_volume_delete.go +++ b/weed/shell/command_volume_delete.go @@ -1,7 +1,7 @@ package shell import ( - "fmt" + "flag" "io" "github.com/chrislusf/seaweedfs/weed/storage/needle" @@ -21,7 +21,7 @@ func (c *commandVolumeDelete) Name() string { func (c *commandVolumeDelete) Help() string { return `delete a live volume from one volume server - volume.delete <volume server host:port> <volume id> + volume.delete -node <volume server host:port> -volumeId <volume id> This command deletes a volume from one volume server. @@ -34,16 +34,16 @@ func (c *commandVolumeDelete) Do(args []string, commandEnv *CommandEnv, writer i return } - if len(args) != 2 { - fmt.Fprintf(writer, "received args: %+v\n", args) - return fmt.Errorf("need 2 args of <volume server host:port> <volume id>") + volDeleteCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError) + volumeIdInt := volDeleteCommand.Int("volumeId", 0, "the volume id") + nodeStr := volDeleteCommand.String("node", "", "the volume server <host>:<port>") + if err = volDeleteCommand.Parse(args); err != nil { + return nil } - sourceVolumeServer, volumeIdString := args[0], args[1] - volumeId, err := needle.NewVolumeId(volumeIdString) - if err != nil { - return fmt.Errorf("wrong volume id format %s: %v", volumeId, err) - } + sourceVolumeServer := *nodeStr + + volumeId := needle.VolumeId(*volumeIdInt) return deleteVolume(commandEnv.option.GrpcDialOption, volumeId, sourceVolumeServer) |
