Class: Cardigan::Command::ListCards

Inherits:
Object
  • Object
show all
Defined in:
lib/cardigan/command/list_cards.rb

Instance Method Summary collapse

Constructor Details

#initialize(repository, io) ⇒ ListCards

Returns a new instance of ListCards.



4
5
6
# File 'lib/cardigan/command/list_cards.rb', line 4

def initialize repository, io
  @repository, @io = repository, io
end

Instance Method Details

#execute(text) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cardigan/command/list_cards.rb', line 8

def execute text
  cards = @repository.cards
  if cards.empty?
    @io.say "There are no cards to display"
    return
  end
  formatter = Cardigan::TextReportFormatter.new @io
  @repository.display_columns.each do |column|
    formatter.add_column(column, @repository.max_field_length(column))
  end
  formatter.output cards
end