diff --git a/cmd/watch_command.go b/cmd/watch_command.go index 60cf7ef..a3bdafd 100644 --- a/cmd/watch_command.go +++ b/cmd/watch_command.go @@ -54,16 +54,14 @@ func WatchCommand(cmd *cobra.Command, args []string) error { return fmt.Errorf("the path needs to be a folder") } - quality, err := cmd.Flags().GetUint8("quality") - if err != nil { + quality := uint8(viper.GetUint16("quality")) + if quality <= 0 { return fmt.Errorf("invalid quality value") } - override, err := cmd.Flags().GetBool("override") - if err != nil { - return fmt.Errorf("invalid quality value") - } + override := viper.GetBool("override") + converterType := constant.FindConversionFormat(viper.GetString("format")) chapterConverter, err := converter.Get(converterType) if err != nil { return fmt.Errorf("failed to get chapterConverter: %v", err) @@ -73,6 +71,7 @@ func WatchCommand(cmd *cobra.Command, args []string) error { if err != nil { return fmt.Errorf("failed to prepare converter: %v", err) } + log.Printf("Watching [%s] with [override: %t, quality: %d, format: %s]", path, override, quality, converterType.String()) events := make(chan inotifywaitgo.FileEvent) errors := make(chan error) diff --git a/converter/constant/format.go b/converter/constant/format.go index 9d77a57..ba652f1 100644 --- a/converter/constant/format.go +++ b/converter/constant/format.go @@ -29,3 +29,14 @@ func ListAll() []string { } return formats } + +func FindConversionFormat(format string) ConversionFormat { + for convFormat, names := range CommandValue { + for _, name := range names { + if name == format { + return convFormat + } + } + } + return DefaultConversion +}