Skip to content

Commit

Permalink
Add line printing fallback for Windows console
Browse files Browse the repository at this point in the history
  • Loading branch information
dmulholl committed Apr 5, 2019
1 parent 37e6ec9 commit c478fb5
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions mp3cat.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"golang.org/x/crypto/ssh/terminal"
"github.com/dmulholland/mp3lib"
"github.com/dmulholland/janus-go/janus"
)


const version = "3.2.0"
const version = "3.3.0"


var helptext = fmt.Sprintf(`
Expand Down Expand Up @@ -184,7 +185,6 @@ func merge(outpath string, inpaths []string, force, quiet, tag bool) {
// Loop over the input files and append their MP3 frames to the output
// file.
for _, inpath := range inpaths {

if !quiet {
fmt.Println("+", inpath)
}
Expand All @@ -198,7 +198,6 @@ func merge(outpath string, inpaths []string, force, quiet, tag bool) {
isFirstFrame := true

for {

// Read the next frame from the input file.
frame := mp3lib.NextFrame(infile)
if frame == nil {
Expand Down Expand Up @@ -373,11 +372,18 @@ func printLine() {
if terminal.IsTerminal(int(os.Stdout.Fd())) {
width, _, err := terminal.GetSize(int(os.Stdout.Fd()))
if err == nil {
fmt.Print("\u001B[90m")
for i := 0; i < width; i++ {
fmt.Print("─")
if runtime.GOOS == "windows" {
for i := 0; i < width; i++ {
fmt.Print("-")
}
fmt.Println()
} else {
fmt.Print("\u001B[90m")
for i := 0; i < width; i++ {
fmt.Print("─")
}
fmt.Println("\u001B[0m")
}
fmt.Println("\u001B[0m")
}
}
}

0 comments on commit c478fb5

Please sign in to comment.