pass presets with args
This commit is contained in:
parent
d59a2859b6
commit
6d045ff304
17
cmd/root.go
17
cmd/root.go
|
@ -27,7 +27,6 @@ import (
|
|||
"github.com/veandco/go-sdl2/sdl"
|
||||
)
|
||||
|
||||
var presets []string
|
||||
var transition bool
|
||||
|
||||
/*
|
||||
|
@ -49,8 +48,8 @@ func checkStdin() error {
|
|||
* validatePresets performs some basic checks on the presets passed in and
|
||||
* returns an error if it finds a problem.
|
||||
*/
|
||||
func validatePresets() error {
|
||||
for _, p := range presets {
|
||||
func validatePresets(cmd *cobra.Command, args []string) error {
|
||||
for _, p := range args {
|
||||
info, err := os.Stat(p)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -145,12 +144,7 @@ func milkbucket(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
defer sdl.Quit()
|
||||
|
||||
err = validatePresets()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
m, err := newMilkDropWindow(800, 600, presets)
|
||||
m, err := newMilkDropWindow(800, 600, args)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -174,7 +168,8 @@ var rootCmd = &cobra.Command{
|
|||
Long: `milkbucket is an audio visualizer.
|
||||
|
||||
It uses Milkdrop preset files to generate visualizations from standard input.`,
|
||||
Run: milkbucket,
|
||||
Run: milkbucket,
|
||||
Args: validatePresets,
|
||||
}
|
||||
|
||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||
|
@ -194,6 +189,4 @@ func init() {
|
|||
// Cobra also supports local flags, which will only run
|
||||
// when this action is called directly.
|
||||
rootCmd.Flags().BoolVarP(&transition, "transition", "t", false, "smoothly transition between presets")
|
||||
|
||||
rootCmd.Flags().StringArrayVarP(&presets, "presets", "p", []string{}, "preset files to use")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue