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 eda92e2d62
commit e88e8e487e

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))
},
}