diff options
| author | Chris Lu <chris.lu@uber.com> | 2019-03-16 13:43:16 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@uber.com> | 2019-03-16 13:43:16 -0700 |
| commit | 657dd2e6c93c02f46b10dfd43fb6e9b38c025ece (patch) | |
| tree | c23a093382d5ffd0d39dd69b68fb24050daa7f3e /weed/command | |
| parent | b92122b885c8fba189f3c503c17478008806fda7 (diff) | |
| download | seaweedfs-657dd2e6c93c02f46b10dfd43fb6e9b38c025ece.tar.xz seaweedfs-657dd2e6c93c02f46b10dfd43fb6e9b38c025ece.zip | |
add shell command to list all collections
Diffstat (limited to 'weed/command')
| -rw-r--r-- | weed/command/shell.go | 59 |
1 files changed, 18 insertions, 41 deletions
diff --git a/weed/command/shell.go b/weed/command/shell.go index 19c5049c5..1c3ce5f10 100644 --- a/weed/command/shell.go +++ b/weed/command/shell.go @@ -1,21 +1,25 @@ package command import ( - "bufio" - "fmt" - "os" + "github.com/chrislusf/seaweedfs/weed/security" + "github.com/chrislusf/seaweedfs/weed/server" + "github.com/chrislusf/seaweedfs/weed/shell" + "github.com/spf13/viper" +) - "github.com/chrislusf/seaweedfs/weed/glog" +var ( + shellOptions shell.ShellOptions ) func init() { cmdShell.Run = runShell // break init cycle + shellOptions.Masters = cmdShell.Flag.String("master", "localhost:9333", "comma-separated master servers") } var cmdShell = &Command{ UsageLine: "shell", - Short: "run interactive commands, now just echo", - Long: `run interactive commands. + Short: "run interactive administrative commands", + Long: `run interactive administrative commands. `, } @@ -23,39 +27,12 @@ var cmdShell = &Command{ var () func runShell(command *Command, args []string) bool { - r := bufio.NewReader(os.Stdin) - o := bufio.NewWriter(os.Stdout) - e := bufio.NewWriter(os.Stderr) - prompt := func() { - var err error - if _, err = o.WriteString("> "); err != nil { - glog.V(0).Infoln("error writing to stdout:", err) - } - if err = o.Flush(); err != nil { - glog.V(0).Infoln("error flushing stdout:", err) - } - } - readLine := func() string { - ret, err := r.ReadString('\n') - if err != nil { - fmt.Fprint(e, err) - os.Exit(1) - } - return ret - } - execCmd := func(cmd string) int { - if cmd != "" { - if _, err := o.WriteString(cmd); err != nil { - glog.V(0).Infoln("error writing to stdout:", err) - } - } - return 0 - } - - cmd := "" - for { - prompt() - cmd = readLine() - execCmd(cmd) - } + + weed_server.LoadConfiguration("security", false) + shellOptions.GrpcDialOption = security.LoadClientTLS(viper.Sub("grpc"), "client") + + shell.RunShell(shellOptions) + + return true + } |
