Class: XCCache::Command::Cache::Clean
- Inherits:
-
XCCache::Command::Cache
- Object
- CLAide::Command
- XCCache::Command
- XCCache::Command::Cache
- XCCache::Command::Cache::Clean
- Defined in:
- lib/xccache/command/cache/clean.rb
Instance Attribute Summary
Attributes inherited from XCCache::Command
#build_options, #install_options
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Clean
constructor
A new instance of Clean.
- #run ⇒ Object
Methods inherited from XCCache::Command
Methods included from XCCache::Config::Mixin
Constructor Details
#initialize(argv) ⇒ Clean
Returns a new instance of Clean.
14 15 16 17 18 19 |
# File 'lib/xccache/command/cache/clean.rb', line 14 def initialize(argv) super @all = argv.flag?("all") @dry = argv.flag?("dry") @targets = argv.arguments! end |
Class Method Details
.options ⇒ Object
7 8 9 10 11 12 |
# File 'lib/xccache/command/cache/clean.rb', line 7 def self. [ ["--all", "Whether to remove all cache (default: false)"], ["--dry", "Dry run - don't remove cache, just show what shall be removed (default: false)"], ].concat(super) end |
Instance Method Details
#run ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/xccache/command/cache/clean.rb', line 21 def run to_remove = @targets.flat_map { |t| config.spm_cache_dir.glob("#{t}/*") } to_remove = config.spm_cache_dir.glob("*/*") if @all to_remove.each do |p| UI.info("Removing #{p.basename.to_s.yellow}") p.rmtree unless @dry end end |