Class: Rfmt::CacheCommands
- Inherits:
-
Thor
- Object
- Thor
- Rfmt::CacheCommands
- Defined in:
- lib/rfmt/cli.rb
Overview
Cache management commands
Instance Method Summary collapse
Instance Method Details
#clear ⇒ Object
17 18 19 20 21 22 |
# File 'lib/rfmt/cli.rb', line 17 def clear cache_opts = [:cache_dir] ? { cache_dir: [:cache_dir] } : {} cache = Cache.new(**cache_opts) cache.clear say 'Cache cleared', :green end |
#prune ⇒ Object
37 38 39 40 41 42 |
# File 'lib/rfmt/cli.rb', line 37 def prune cache_opts = [:cache_dir] ? { cache_dir: [:cache_dir] } : {} cache = Cache.new(**cache_opts) pruned = cache.prune say "Pruned #{pruned} stale cache entries", :green end |
#stats ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/rfmt/cli.rb', line 26 def stats cache_opts = [:cache_dir] ? { cache_dir: [:cache_dir] } : {} cache = Cache.new(**cache_opts) stats = cache.stats say "Cache directory: #{stats[:cache_dir]}", :blue say "Total files in cache: #{stats[:total_files]}", :blue say "Cache size: #{(stats[:cache_size_bytes] / 1024.0).round(2)} KB", :blue end |