MCPcopy Index your code
hub / github.com/cli/cli / NewCmdConfigClearCache

Function NewCmdConfigClearCache

pkg/cmd/config/clear-cache/clear_cache.go:19–42  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*ClearCacheOptions) error)

Source from the content-addressed store, hash-verified

17}
18
19func 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
44func clearCacheRun(opts *ClearCacheOptions) error {
45 if err := os.RemoveAll(opts.CacheDir); err != nil {

Callers

nothing calls this directly

Calls 2

clearCacheRunFunction · 0.85
CacheDirMethod · 0.65

Tested by

no test coverage detected