diff options
| -rw-r--r-- | actions.go | 4 | ||||
| -rw-r--r-- | brewget.go | 11 | ||||
| -rw-r--r-- | main.go | 9 |
3 files changed, 18 insertions, 6 deletions
@@ -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{} @@ -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 { @@ -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) }, }, { |
