go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/projects/blogctl/pkg/cmd/clean.go (about) 1 /* 2 3 Copyright (c) 2023 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package cmd 9 10 import ( 11 "context" 12 "os" 13 "strings" 14 15 "github.com/urfave/cli/v2" 16 "go.charczuk.com/sdk/logutil" 17 "go.charczuk.com/sdk/slant" 18 19 "go.charczuk.com/projects/blogctl/pkg/config" 20 "go.charczuk.com/projects/blogctl/pkg/engine" 21 ) 22 23 // Clean returns the clean command. 24 func Clean() *cli.Command { 25 cmd := &cli.Command{ 26 Name: "clean", 27 Usage: "Clean caches", 28 Action: func(ctx *cli.Context) error { 29 cfg, flags, cfgPaths, err := config.ReadConfig(ctx) 30 if err != nil { 31 return err 32 } 33 34 log := Logger("clean") 35 slant.Print(os.Stdout, "BLOGCTL") 36 if len(cfgPaths) > 0 { 37 logutil.Infof(log, "using config path(s): %s", strings.Join(cfgPaths, ", ")) 38 } 39 40 return engine.MustNew( 41 engine.OptConfig(cfg), 42 engine.OptLog(log), 43 engine.OptParallelism(flags.Parallelism), 44 engine.OptDryRun(flags.DryRun), 45 ).CleanThumbnailCache(context.Background()) 46 }, 47 } 48 return cmd 49 }