Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

cmd: improved cache-clear command #16

Merged
merged 1 commit into from
Jul 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cmd/cache_clear.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package cmd

import (
"fmt"
"os"

"github.com/i582/cfmt/cmd/cfmt"
)

func CacheClear() (int, error) {
cacheDir := DefaultCacheDir()
if cacheDir == "/" || cacheDir == "" {
panic(fmt.Sprintf("attempted to rm -rf %s", cacheDir))
cfmt.Printf("Cache clearing error: attempted to {{rm -rf %s}}::red", cacheDir)
return 2, nil
}
err := os.RemoveAll(cacheDir)
cfmt.Println("The cache has been {{successfully}}::green deleted.")
return 0, err
}