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

cmd: added cache-clear command #14

Merged
merged 1 commit into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions cmd/cache_clear.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package cmd

import (
"fmt"
"os"
)

func CacheClear() (int, error) {
cacheDir := DefaultCacheDir()
if cacheDir == "/" || cacheDir == "" {
panic(fmt.Sprintf("attempted to rm -rf %s", cacheDir))
}
err := os.RemoveAll(cacheDir)
return 0, err
}
8 changes: 8 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ func Main() {
},
})

app.Commands = append(app.Commands, &cmd.Command{
Name: "cache-clear",
Description: "The command clears the cache",
Action: func(ctx *cmd.AppContext) (int, error) {
return CacheClear()
},
})

app.Commands = append(app.Commands, &cmd.Command{
Name: "init",
Description: "The command to create a template palette in the project folder",
Expand Down