This repository has been archived by the owner on Oct 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
printer.go
78 lines (68 loc) · 1.52 KB
/
printer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"fmt"
"os"
"strings"
"github.com/elboletaire/remuxing/models"
"github.com/logrusorgru/aurora"
"github.com/mattn/go-colorable"
)
func usage() {
cmd := os.Args[0]
s := aurora.Yellow("Usage:\n\n").String()
s += fmt.Sprintf(
aurora.Gray(
gray,
" %s -output [file] -languages [langs] [inputs...]\n\n",
).String(),
cmd,
)
s += aurora.Yellow("Usage example:\n\n").String()
s += fmt.Sprintf(
aurora.Gray(
gray,
" %s -v -output output.mkv -languages eng,spa input1.mkv input2.mkv input3.mkv",
).String(),
cmd,
)
s += strings.Repeat("\n", 3)
fmt.Fprint(colorable.NewColorableStdout(), s)
}
func printCommand(command []string) {
title("COMMAND")
fmt.Fprintf(
colorable.NewColorableStdout(),
aurora.Gray(15, "$ mkvmerge %s\n").String(), strings.Join(command, " "),
)
}
func syntaxError(err string) {
fmt.Println(fmt.Sprintf("syntax error: %s", err))
os.Exit(1)
}
func title(text string) {
fmt.Fprintf(
colorable.NewColorableStdout(),
aurora.Yellow("\n\n %s\n %s %s %s\n %s\n\n").String(),
strings.Repeat("#", len(text)+4),
"#",
text,
"#",
strings.Repeat("#", len(text)+4),
)
}
func printTracks(text string, tracks models.Tracks) {
title(text)
for _, track := range tracks {
printTrack(&track)
}
}
func printTrack(track *models.TrackController) {
fmt.Fprintf(
colorable.NewColorableStdout(),
aurora.Green("- Track ID %d (%s in %s) from file %s\n").String(),
track.Track.ID,
track.Track.Codec,
track.Track.Properties.Language,
track.Input.FileName,
)
}