Skip to content

Commit 3fa0007

Browse files
committed
Factor out PrintFlagsSummary
1 parent 4ea2951 commit 3fa0007

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

markut.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ func defaultContext() (EvalContext, bool) {
196196
return context, true
197197
}
198198

199+
func PrintFlagsSummary(flags []Token) {
200+
locWidth := 0
201+
for _, flag := range flags {
202+
// TODO: Loc.String() should include the extra ":", but that requires a huge refactoring in all the places where call it explicitly or implicitly
203+
locWidth = max(locWidth, len(flag.Loc.String()) + 1)
204+
}
205+
// TODO: merge together parameters defined on the same line
206+
for _, flag := range flags {
207+
fmt.Printf("%-*s %s\n", locWidth, flag.Loc.String() + ":", string(flag.Text))
208+
}
209+
}
210+
199211
func (context EvalContext) PrintSummary() error {
200212
fmt.Printf(">>> Main Output Parameters:\n")
201213
if context.VideoCodec != nil {
@@ -219,19 +231,14 @@ func (context EvalContext) PrintSummary() error {
219231
fmt.Printf("Audio Bitrate: %s (Default)\n", DefaultAudioBitrate)
220232
}
221233
fmt.Println()
222-
// TODO: merge together parameters defined on the same line
223234
if len(context.ExtraInFlags) > 0 {
224235
fmt.Printf(">>> Extra Input Parameters:\n")
225-
for _, inFlag := range context.ExtraInFlags {
226-
fmt.Printf("%s: %s\n", inFlag.Loc, string(inFlag.Text))
227-
}
236+
PrintFlagsSummary(context.ExtraInFlags)
228237
fmt.Println()
229238
}
230239
if len(context.ExtraOutFlags) > 0 {
231240
fmt.Printf(">>> Extra Output Parameters:\n")
232-
for _, outFlag := range context.ExtraOutFlags {
233-
fmt.Printf("%s: %s\n", outFlag.Loc, string(outFlag.Text))
234-
}
241+
PrintFlagsSummary(context.ExtraOutFlags)
235242
fmt.Println()
236243
}
237244
TwitchVodFileRegexp := "([0-9]+)-[0-9a-f\\-]+\\.mp4"

0 commit comments

Comments
 (0)