Add newline for read file command if output is stdout

This commit is contained in:
Elara 2021-11-25 19:44:43 -08:00
parent 38119435f1
commit cb8fb2c0bc
1 changed files with 4 additions and 0 deletions

View File

@ -46,9 +46,11 @@ var readCmd = &cobra.Command{
log.Fatal().Err(err).Msg("Error moving file or directory")
}
var suffix string
var out *os.File
if args[1] == "-" {
out = os.Stdout
suffix = "\n"
} else {
out, err = os.Create(args[1])
if err != nil {
@ -60,6 +62,8 @@ var readCmd = &cobra.Command{
if err != nil {
log.Fatal().Err(err).Msg("Error writing to local file")
}
out.WriteString(suffix)
log.Info().Msgf("Read %d bytes in %s", n, time.Since(start))
},
}