Skip to content

Commit 9b37c7e

Browse files
committed
feat: add repeat advanced argument for playlist end behaviour
Add RepeatOff/RepeatAll/RepeatOne constants and a Repeat field to PlaylistArgs (oneof=off all one). Add IsRepeatAll/IsRepeatOne helpers mirroring IsModeShuffle. The existing mode=shuffle arg is unchanged.
1 parent 9722898 commit 9b37c7e

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

advargs.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,13 @@ func IsActionRun(action string) bool {
3131
func IsModeShuffle(mode string) bool {
3232
return strings.EqualFold(mode, ModeShuffle)
3333
}
34+
35+
// IsRepeatAll returns true if the repeat value is "all" (case-insensitive).
36+
func IsRepeatAll(repeat string) bool {
37+
return strings.EqualFold(repeat, RepeatAll)
38+
}
39+
40+
// IsRepeatOne returns true if the repeat value is "one" (case-insensitive).
41+
func IsRepeatOne(repeat string) bool {
42+
return strings.EqualFold(repeat, RepeatOne)
43+
}

types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const (
4747
KeySlot Key = "slot"
4848
KeyTags Key = "tags"
4949
KeyMode Key = "mode"
50+
KeyRepeat Key = "repeat"
5051
KeyName Key = "name"
5152
KeyPreNotice Key = "pre_notice"
5253
KeyHidden Key = "hidden"
@@ -66,6 +67,16 @@ const (
6667
ModeShuffle = "shuffle"
6768
)
6869

70+
// Repeat values for the repeat advanced argument.
71+
const (
72+
// RepeatOff stops playback at the end of the playlist (default).
73+
RepeatOff = "off"
74+
// RepeatAll loops the whole playlist back to the start when it ends.
75+
RepeatAll = "all"
76+
// RepeatOne repeats the current track indefinitely.
77+
RepeatOne = "one"
78+
)
79+
6980
// GlobalArgs contains advanced arguments available to all commands.
7081
type GlobalArgs struct {
7182
// When controls conditional execution. If non-empty and falsy, command is skipped.
@@ -164,6 +175,8 @@ type PlaylistArgs struct {
164175
GlobalArgs
165176
// Mode controls playlist behavior (e.g., "shuffle").
166177
Mode string `advarg:"mode" validate:"omitempty,oneof=shuffle"`
178+
// Repeat controls end-of-playlist behaviour: off (default), all (loop playlist), one (repeat track).
179+
Repeat string `advarg:"repeat" validate:"omitempty,oneof=off all one"`
167180
// Slot selects the media slot for playlist routing.
168181
Slot string `advarg:"slot"`
169182
}

0 commit comments

Comments
 (0)