Skip to content

Commit

Permalink
updated client
Browse files Browse the repository at this point in the history
  • Loading branch information
kinfkong committed Jun 3, 2022
1 parent 78d25bd commit f8d1050
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
33 changes: 17 additions & 16 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,35 +105,36 @@ func (client *Client) RunKatago(options RunKatagoOptions, subCommands []string,
}

// ViewConfig views the katago config
func (client *Client) ViewConfig(options RunKatagoOptions, subCommands []string, inputReader io.Reader, outputWriter io.Writer, stderrWriter io.Writer, onReady func()) (*SessionResult, error) {
func (client *Client) ViewConfig(options RunKatagoOptions, subCommands []string, outputWriter io.Writer) error {
if !client.init {
err := client.initClient()
if err != nil {
return nil, err
return err
}
}
if options.KataLocalConfig != nil {
// run scp to copy the configure
err := (&katassh.KataSSHSession{}).RunSCP(client.sshOptions, *options.KataLocalConfig, client.BuildServerLocationOptions())
if err != nil {
return nil, err
return err
}
}

stdinReader, mockWriter := io.Pipe()
mockReader, stderrWriter := io.Pipe()
defer mockWriter.Close()
defer stdinReader.Close()
defer mockReader.Close()
defer stderrWriter.Close()

s := &katassh.KataSSHSession{}
result := SessionResult{
session: s,
}
// build the ssh command
result.wg.Add(1)
go func() {
err := s.RunKatago(client.sshOptions, client.BuildKatagoCommand("view-config", options, subCommands), inputReader, outputWriter, stderrWriter, options.UseRawData, onReady)
if err != nil {
result.Err = err
}
result.wg.Done()
}()

return &result, nil
// build the ssh command
err := s.RunSSH(client.sshOptions, client.BuildKatagoCommand("view-config", options, subCommands), stdinReader, stderrWriter, outputWriter)
if err != nil {
return err
}
return nil
}

// QueryServer queries the server
Expand Down
7 changes: 3 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

const (
AppVersion = "1.5.1"
AppVersion = "1.6.0"
)

var opts struct {
Expand Down Expand Up @@ -116,7 +116,7 @@ func main() {
log.Fatal("Failed to query server.", err)
}
} else if opts.Command == "view-config" {
sessionResult, err := remoteClient.ViewConfig(client.RunKatagoOptions{
err := remoteClient.ViewConfig(client.RunKatagoOptions{
NoCompress: opts.NoCompress,
RefreshInterval: opts.RefreshInterval,
TransmitMoveNum: opts.TransmitMoveNum,
Expand All @@ -126,12 +126,11 @@ func main() {
KataWeight: opts.KataWeight,
KataName: opts.KataName,
UseRawData: false,
}, subCommands, os.Stdin, os.Stdout, os.Stderr, nil)
}, subCommands, os.Stdout)
if err != nil {
log.Printf("ERROR view katago config failed: %v", err)
log.Fatal("Failed to view katago config.", err)
}
sessionResult.Wait()
} else {
log.Fatal(fmt.Sprintf("Unknown command: [%s]", opts.Command))
}
Expand Down

0 comments on commit f8d1050

Please sign in to comment.