Class: Yap::Cli::Commands::Addon::List

Inherits:
Object
  • Object
show all
Defined in:
lib/yap/cli/commands/addon/list.rb

Instance Method Summary collapse

Instance Method Details

#filter=(filter_kind) ⇒ Object



5
6
7
# File 'lib/yap/cli/commands/addon/list.rb', line 5

def filter=(filter_kind)
  @filter = filter_kind
end

#processObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/yap/cli/commands/addon/list.rb', line 9

def process
  configuration = Yap.configuration

  addon_refs = ::Yap::Addon::Path.
    find_for_configuration(configuration)
  if addon_refs.empty?
    puts <<-MSG.strip_heredoc
      |No addons found searching paths:
      |  - #{configuration.addon_paths.join("\n  -")}
    MSG
  elsif @filter == :enabled
    addon_refs.select(&:enabled?).each do |addon_ref|
      puts "#{addon_ref.name}"
    end
  elsif @filter == :disabled
    addon_refs.select(&:disabled?).each do |addon_ref|
      puts "#{addon_ref.name}"
    end
  else
    addon_refs.each do |addon_ref|
      enabled_or_disabled = addon_ref.enabled? ? 'enabled' : 'disabled'
      puts "#{addon_ref.name} (#{enabled_or_disabled})"
    end
  end
end