shell: move volume operations to use flag parsing arguments

This commit is contained in:
Chris Lu
2020-09-20 09:27:34 -07:00
parent fcbc520373
commit f498c71199
7 changed files with 60 additions and 52 deletions

View File

@@ -2,6 +2,7 @@ package shell
import (
"context"
"flag"
"fmt"
"github.com/chrislusf/seaweedfs/weed/storage/needle"
"io"
@@ -50,11 +51,14 @@ func (c *commandVolumeFixReplication) Do(args []string, commandEnv *CommandEnv,
return
}
takeAction := true
if len(args) > 0 && args[0] == "-n" {
takeAction = false
volFixReplicationCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
skipChange := volFixReplicationCommand.Bool("n", false, "skip the changes")
if err = volFixReplicationCommand.Parse(args); err != nil {
return nil
}
takeAction := !*skipChange
var resp *master_pb.VolumeListResponse
err = commandEnv.MasterClient.WithClient(func(client master_pb.SeaweedClient) error {
resp, err = client.VolumeList(context.Background(), &master_pb.VolumeListRequest{})