summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions.go4
-rw-r--r--brewget.go11
-rw-r--r--main.go9
3 files changed, 18 insertions, 6 deletions
diff --git a/actions.go b/actions.go
index d672332..ce77e1c 100644
--- a/actions.go
+++ b/actions.go
@@ -94,8 +94,8 @@ func initStat(pkgName string) *statistics {
return stat
}
-func runList() error {
- depmap := GetBrewDeps()
+func runList(useCache bool) error {
+ depmap := GetBrewDeps(useCache)
list := GetBrewList()
keys := []string{}
diff --git a/brewget.go b/brewget.go
index b5c8c8a..5b33b01 100644
--- a/brewget.go
+++ b/brewget.go
@@ -118,14 +118,19 @@ func GetBrewList() []string {
return list
}
-func GetBrewDeps() map[string][]string {
+func GetBrewDeps(useCache bool) map[string][]string {
depmap := map[string][]string{}
// Try reading from cache
const cachepath = "depmap.json"
- cache_data, cache_hit := ReadCache(cachepath, brewDepCacheTTL)
+ var cache_data []byte
+ var cache_hit bool
- if cache_hit {
+ if (useCache) {
+ cache_data, cache_hit = ReadCache(cachepath, brewDepCacheTTL)
+ }
+
+ if cache_hit && useCache {
// if cache hit, decode
err := json.Unmarshal(cache_data, &depmap)
if err != nil {
diff --git a/main.go b/main.go
index d58fba3..6ea78c1 100644
--- a/main.go
+++ b/main.go
@@ -73,9 +73,16 @@ func main() {
Value: false,
Destination: &ListNoDep,
},
+ &cli.BoolFlag{
+ Name: "no-cache",
+ Aliases: []string{"nc"},
+ Usage: "Disable caching",
+ Value: false,
+ Destination: &NoCache,
+ },
},
Action: func(ctx context.Context, cmd *cli.Command) error {
- return runList()
+ return runList(!NoCache)
},
},
{