diff --git a/cmd/root.go b/cmd/root.go index 42087d1..693fe58 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -5,9 +5,11 @@ package cmd import ( "fmt" + "log" + "os" + "github.com/spf13/cobra" "github.com/spf13/viper" - "os" ) var cfgFile string @@ -20,6 +22,9 @@ var rootCmd = &cobra.Command{ // Uncomment the following line if your bare application // has an action associated with it: Run: func(cmd *cobra.Command, args []string) { + if err := setClientParameters(cmd); err != nil { + log.Fatalf("Error occurred setting parameters: %v\n", err) + } tune() }, } @@ -45,6 +50,8 @@ func init() { // Cobra also supports local flags, which will only run // when this action is called directly. rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + rootCmd.PersistentFlags().StringP("file", "f", "", "File to play") + rootCmd.PersistentFlags().StringP("directory", "d", "", "Directory to look for files to play") } // initConfig reads in config file and ENV variables if set. @@ -70,3 +77,21 @@ func initConfig() { fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed()) } } + +func setClientParameters(cmd *cobra.Command) error { + parameterFile, err := cmd.Flags().GetString("file") + if err != nil { + return err + } + if parameterFile != "" { + playIndividualFile = true + filePath = parameterFile + } + parameterDir, err := cmd.Flags().GetString("directory") + if err != nil { + return err + } + if parameterDir != "" { + } + return nil +} diff --git a/cmd/ui.go b/cmd/ui.go deleted file mode 100644 index a30eeac..0000000 --- a/cmd/ui.go +++ /dev/null @@ -1,9 +0,0 @@ -package cmd - -import ( -// "github.com/jroimartin/gocui" -) - -func UI() { - //g, err := gocui.NewGui() -}