mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-09-11 12:55:54 +03:00
Re-enable cache by default
Why?
With SHA fingerprinting speeds improved drastically by
f618d8a796
, we can now re-enable
caching by default.
This introduces a -C flag to disable the cache for a run.
Note that the cache is always invalidated when files are modified.
This commit is contained in:
parent
792d0dca05
commit
0505b4bff3
18
app/Main.hs
18
app/Main.hs
@ -22,7 +22,7 @@ data Options = Options
|
||||
, oAllLikelihoods :: Bool
|
||||
, oIgnoredPaths :: [String]
|
||||
, oGrouping :: CurrentGrouping
|
||||
, oWithCache :: Bool
|
||||
, oWithoutCache :: Bool
|
||||
, oFromStdIn :: Bool
|
||||
}
|
||||
|
||||
@ -74,8 +74,8 @@ calculateTagInput Options{ oFromStdIn = True } = loadTagsFromPipe
|
||||
calculateTagInput Options{ oFromStdIn = False } = loadTagsFromFile
|
||||
|
||||
withCache :: Options -> IO SearchResults -> IO SearchResults
|
||||
withCache Options{ oWithCache = True } = fmap SearchResults . cached "term-matches" . fmap fromResults
|
||||
withCache Options{ oWithCache = False } = id
|
||||
withCache Options{ oWithoutCache = True } = id
|
||||
withCache Options{ oWithoutCache = False } = fmap SearchResults . cached "term-matches" . fmap fromResults
|
||||
|
||||
withInfo :: Parser a -> String -> String -> String -> ParserInfo a
|
||||
withInfo opts h d f =
|
||||
@ -104,7 +104,7 @@ parseOptions =
|
||||
<*> parseAllLikelihoods
|
||||
<*> parseIgnorePaths
|
||||
<*> parseGroupings
|
||||
<*> parseWithCache
|
||||
<*> parseWithoutCache
|
||||
<*> parseFromStdIn
|
||||
|
||||
parseSearchRunner :: Parser SearchRunner
|
||||
@ -166,11 +166,11 @@ parseGroupingOption = strOption $
|
||||
<> long "group-by"
|
||||
<> help "[Allowed: directory, term, file, none] Group results"
|
||||
|
||||
parseWithCache :: Parser Bool
|
||||
parseWithCache = switch $
|
||||
short 'c'
|
||||
<> long "with-cache"
|
||||
<> help "Write to cache and read when available"
|
||||
parseWithoutCache :: Parser Bool
|
||||
parseWithoutCache = switch $
|
||||
short 'C'
|
||||
<> long "no-cache"
|
||||
<> help "Ignore cache when performing calculations"
|
||||
|
||||
parseFromStdIn :: Parser Bool
|
||||
parseFromStdIn = switch $
|
||||
|
Loading…
Reference in New Issue
Block a user