(f *cmdutil.Factory, runF func(*ClearCacheOptions) error)
| 17 | } |
| 18 | |
| 19 | func NewCmdConfigClearCache(f *cmdutil.Factory, runF func(*ClearCacheOptions) error) *cobra.Command { |
| 20 | opts := &ClearCacheOptions{ |
| 21 | IO: f.IOStreams, |
| 22 | CacheDir: config.CacheDir(), |
| 23 | } |
| 24 | |
| 25 | cmd := &cobra.Command{ |
| 26 | Use: "clear-cache", |
| 27 | Short: "Clear the cli cache", |
| 28 | Example: heredoc.Doc(` |
| 29 | # Clear the cli cache |
| 30 | $ gh config clear-cache |
| 31 | `), |
| 32 | Args: cobra.ExactArgs(0), |
| 33 | RunE: func(_ *cobra.Command, _ []string) error { |
| 34 | if runF != nil { |
| 35 | return runF(opts) |
| 36 | } |
| 37 | return clearCacheRun(opts) |
| 38 | }, |
| 39 | } |
| 40 | |
| 41 | return cmd |
| 42 | } |
| 43 | |
| 44 | func clearCacheRun(opts *ClearCacheOptions) error { |
| 45 | if err := os.RemoveAll(opts.CacheDir); err != nil { |
nothing calls this directly
no test coverage detected