Add trailing newline to output if it's not present yet

This commit is contained in:
maride 2020-01-08 08:55:31 +01:00
parent 22da3cc934
commit 0051217bb5

View File

@ -3,6 +3,7 @@ package output
import ( import (
"fmt" "fmt"
"github.com/fatih/color" "github.com/fatih/color"
"strings"
) )
const ( const (
@ -42,8 +43,13 @@ func PrintBlock(headline string, content string) {
content = cutContent(content) content = cutContent(content)
} }
// And print our content. // Print our content.
fmt.Print(content) fmt.Print(content)
// Check if we need to add a newline character at the end
if !strings.HasSuffix(content, "\n") {
fmt.Print("\n")
}
} }
// Cut content after MaxContentLines lines // Cut content after MaxContentLines lines