Class: Mnenv::SnapCommand
- Inherits:
-
Thor
- Object
- Thor
- Mnenv::SnapCommand
- Defined in:
- lib/mnenv/commands/snap_command.rb
Instance Method Summary collapse
Instance Method Details
#list ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/mnenv/commands/snap_command.rb', line 14 def list repo = SnapRepository.new versions = repo.all case [:format] when 'json' output = JsonFormatter.format_versions(versions) output['platform'] = 'snap' puts JSON.pretty_generate(output) else list_versions_text(versions, 'Snap') end end |
#refresh ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mnenv/commands/snap_command.rb', line 29 def refresh fetcher = Snap::Fetcher.new existing = fetcher.repository.all.map(&:version) remote_versions = fetcher.fetch_all new_versions = remote_versions.reject { |v| existing.include?(v.version) } if new_versions.empty? puts 'No new Snap versions found' else repo.save_all(new_versions) puts "Added #{new_versions.size} new Snap versions" end end |
#revamp ⇒ Object
44 45 46 47 48 |
# File 'lib/mnenv/commands/snap_command.rb', line 44 def revamp fetcher = Snap::Fetcher.new versions = fetcher.fetch_and_save puts "Revamped #{versions.size} Snap versions" end |
#update(version) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/mnenv/commands/snap_command.rb', line 51 def update(version) fetcher = Snap::Fetcher.new versions = fetcher.fetch_all target = versions.find { |v| v.version == version } if target.nil? puts "Snap version #{version} not found" exit 1 end fetcher.repository.save_all([target]) puts "Updated 1 Snap entry for version #{version}:" target.channels.each do |v| puts " - channel: #{v.name} arch: #{v.arch} revision: #{v.revision}" end end |