forked from go-flutter-desktop/hover
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean-cache.go
36 lines (30 loc) · 890 Bytes
/
clean-cache.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package cmd
import (
"os"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/sudonims/hover/internal/enginecache"
"github.com/sudonims/hover/internal/log"
)
var cachePath string
func init() {
cleanCacheCmd.Flags().StringVar(&cachePath, "cache-path", enginecache.DefaultCachePath(), "The path that hover uses to cache dependencies such as the Flutter engine .so/.dll")
rootCmd.AddCommand(cleanCacheCmd)
}
var cleanCacheCmd = &cobra.Command{
Use: "clean-cache",
Short: "Clean cached engine files",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
return errors.New("does not take arguments")
}
return nil
},
Run: func(cmd *cobra.Command, args []string) {
err := os.RemoveAll(enginecache.BaseEngineCachePath(cachePath))
if err != nil {
log.Errorf("Failed to delete engine cache directory: %v", err)
os.Exit(1)
}
},
}