Class: Wavesync::Commands::ClearCache
- Defined in:
- lib/wavesync/commands/clear_cache.rb
Constant Summary collapse
- DEVICE_OPTION =
Option.new(short: '-d', long: '--device NAME', description: 'Clear cache for a specific device only')
Instance Method Summary collapse
-
#run ⇒ Object
: () -> void.
Methods inherited from Command
Instance Method Details
#run ⇒ Object
: () -> void
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/wavesync/commands/clear_cache.rb', line 18 def run , config = (banner: 'Usage: wavesync clear-cache [options]') do |opts, opts_hash| opts.on(*DEVICE_OPTION.to_a) { |value| opts_hash[:device] = value } end mtp_devices = config.device_configs.select { |device_config| device_config[:transport] == 'mtp' } if [:device] mtp_devices = mtp_devices.select { |device_config| device_config[:name] == [:device] } if mtp_devices.empty? puts "No MTP device named \"#{[:device]}\" found in config." exit 1 end end if mtp_devices.empty? puts 'No MTP devices configured.' return end mtp_devices.each { |device_config| clear_one(device_config[:name]) } end |