mirror of
https://github.com/Belphemur/CBZOptimizer.git
synced 2025-10-14 20:38:52 +02:00
feat(split): Make the split configurable for the watch command
This commit is contained in:
@@ -35,6 +35,9 @@ func init() {
|
|||||||
command.Flags().BoolP("override", "o", true, "Override the original CBZ files")
|
command.Flags().BoolP("override", "o", true, "Override the original CBZ files")
|
||||||
_ = viper.BindPFlag("override", command.Flags().Lookup("override"))
|
_ = viper.BindPFlag("override", command.Flags().Lookup("override"))
|
||||||
|
|
||||||
|
command.Flags().BoolP("split", "s", false, "Split long pages into smaller chunks")
|
||||||
|
_ = viper.BindPFlag("split", command.Flags().Lookup("split"))
|
||||||
|
|
||||||
command.PersistentFlags().VarP(
|
command.PersistentFlags().VarP(
|
||||||
formatFlag,
|
formatFlag,
|
||||||
"format", "f",
|
"format", "f",
|
||||||
@@ -61,6 +64,8 @@ func WatchCommand(_ *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
override := viper.GetBool("override")
|
override := viper.GetBool("override")
|
||||||
|
|
||||||
|
split := viper.GetBool("split")
|
||||||
|
|
||||||
converterType := constant.FindConversionFormat(viper.GetString("format"))
|
converterType := constant.FindConversionFormat(viper.GetString("format"))
|
||||||
chapterConverter, err := converter.Get(converterType)
|
chapterConverter, err := converter.Get(converterType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -109,7 +114,13 @@ func WatchCommand(_ *cobra.Command, args []string) error {
|
|||||||
for _, e := range event.Events {
|
for _, e := range event.Events {
|
||||||
switch e {
|
switch e {
|
||||||
case inotifywaitgo.CLOSE_WRITE, inotifywaitgo.MOVE:
|
case inotifywaitgo.CLOSE_WRITE, inotifywaitgo.MOVE:
|
||||||
err := utils.Optimize(chapterConverter, event.Filename, quality, override)
|
err := utils.Optimize(&utils.OptimizeOptions{
|
||||||
|
ChapterConverter: chapterConverter,
|
||||||
|
Path: path,
|
||||||
|
Quality: quality,
|
||||||
|
Override: override,
|
||||||
|
Split: split,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors <- fmt.Errorf("error processing file %s: %w", event.Filename, err)
|
errors <- fmt.Errorf("error processing file %s: %w", event.Filename, err)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user