Fix tile38-cli output showing protocol size when piping

fixes #603
This commit is contained in:
tidwall 2021-03-30 08:59:25 -07:00
parent bac9cebc51
commit 84a5120bc3
1 changed files with 3 additions and 12 deletions

View File

@ -61,9 +61,8 @@ func showHelp() bool {
} }
fmt.Fprintf(os.Stdout, "tile38-cli %s%s\n\n", core.Version, gitsha) fmt.Fprintf(os.Stdout, "tile38-cli %s%s\n\n", core.Version, gitsha)
fmt.Fprintf(os.Stdout, "Usage: tile38-cli [OPTIONS] [cmd [arg [arg ...]]]\n") fmt.Fprintf(os.Stdout, "Usage: tile38-cli [OPTIONS] [cmd [arg [arg ...]]]\n")
fmt.Fprintf(os.Stdout, " --raw Use raw formatting for replies (default when STDOUT is not a tty)\n") fmt.Fprintf(os.Stdout, " --raw Use raw formatting for replies\n")
fmt.Fprintf(os.Stdout, " --noprompt Do not display a prompt\n") fmt.Fprintf(os.Stdout, " --noprompt Do not display a prompt\n")
fmt.Fprintf(os.Stdout, " --tty Force TTY\n")
fmt.Fprintf(os.Stdout, " --resp Use RESP output formatting (default is JSON output)\n") fmt.Fprintf(os.Stdout, " --resp Use RESP output formatting (default is JSON output)\n")
fmt.Fprintf(os.Stdout, " --json Use JSON output formatting (default is JSON output)\n") fmt.Fprintf(os.Stdout, " --json Use JSON output formatting (default is JSON output)\n")
fmt.Fprintf(os.Stdout, " -h <hostname> Server hostname (default: %s)\n", hostname) fmt.Fprintf(os.Stdout, " -h <hostname> Server hostname (default: %s)\n", hostname)
@ -146,14 +145,6 @@ func main() {
return return
} }
if !raw && !tty && runtime.GOOS != "windows" {
fi, err := os.Stdout.Stat()
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
return
}
raw = (fi.Mode() & os.ModeCharDevice) == 0
}
if len(oneCommand) > 0 && (oneCommand[0] == 'h' || oneCommand[0] == 'H') && strings.Split(strings.ToLower(oneCommand), " ")[0] == "help" { if len(oneCommand) > 0 && (oneCommand[0] == 'h' || oneCommand[0] == 'H') && strings.Split(strings.ToLower(oneCommand), " ")[0] == "help" {
showHelp() showHelp()
return return
@ -490,7 +481,7 @@ func help(arg string) error {
} }
fmt.Fprintf(os.Stderr, ` "quit" to exit`+"\n") fmt.Fprintf(os.Stderr, ` "quit" to exit`+"\n")
if noprompt && tty { if noprompt && tty {
fmt.Fprintf(os.Stderr, groups) fmt.Fprint(os.Stderr, groups)
} }
return nil return nil
} }
@ -512,7 +503,7 @@ func help(arg string) error {
} }
if showGroups { if showGroups {
if noprompt && tty { if noprompt && tty {
fmt.Fprintf(os.Stderr, groups) fmt.Fprint(os.Stderr, groups)
} }
} else if !found { } else if !found {
if noprompt && tty { if noprompt && tty {