forked from gotracker/gotracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaylist_example.go
More file actions
79 lines (69 loc) · 1.74 KB
/
Copy pathplaylist_example.go
File metadata and controls
79 lines (69 loc) · 1.74 KB
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
79
package command
import (
"io"
"os"
"path/filepath"
"github.com/gotracker/gotracker/internal/playlist"
"github.com/heucuva/optional"
"github.com/spf13/cobra"
)
var (
pmPath string = filepath.Join(".", "2ND_PM.S3M")
skavPath string = filepath.Join(".", "2ND_SKAV.S3M")
playlistExampleOutputFilepath string
)
func init() {
if flags := playlistExampleCmd.Flags(); flags != nil {
flags.StringVarP(&playlistExampleOutputFilepath, "output", "o", playlistExampleOutputFilepath, "output path [blank for stdout]")
}
playlistCmd.AddCommand(playlistExampleCmd)
}
var (
playlistExampleCmd = &cobra.Command{
Use: "example",
Short: "Create an example playlist file",
Long: `Create an example playlist file.`,
RunE: func(cmd *cobra.Command, args []string) error {
pl := playlist.New()
pl.Add(playlist.Song{
Filepath: skavPath,
End: playlist.Position{
Order: optional.NewValue(15),
//Row: optional.NewValue(0),
},
})
pl.Add(playlist.Song{
Filepath: pmPath,
End: playlist.Position{
Order: optional.NewValue(83),
Row: optional.NewValue(56),
},
})
pl.Add(playlist.Song{
Filepath: skavPath,
Start: playlist.Position{
Order: optional.NewValue(18),
//Row: optional.NewValue(0),
},
Loop: playlist.Loop{
Count: playlist.NewLoopForever(),
},
})
var ow io.Writer = os.Stdout
if playlistExampleOutputFilepath != "" {
basePath := filepath.Dir(playlistExampleOutputFilepath)
if basePath != "" && basePath != "." {
if err := os.MkdirAll(basePath, 0755); err != nil {
return err
}
}
var err error
ow, err = os.Create(playlistExampleOutputFilepath)
if err != nil {
return err
}
}
return pl.WriteYAML(ow)
},
}
)