Sha256: e0977255f591f50140f851d5b7c6c6c49f2c819dd6719659df02f89623739a75

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

module TrelloCli
  module CLI
    module Board
      class List

        def initialize
          @options = {}
        end

        def run
          option_parser.parse!

          list_boards(@options[:closed]).each do |board|
            name   = board.attributes[:name]
            id     = board.attributes[:id]
            closed = board.attributes[:closed]
            puts "#{name} ( #{id} )"
          end
        end

        private

        def list_boards(include_closed)
          lb = TrelloCli::Requests::ListBoards.new

          lb.list.select do |b|
            closed = b.attributes[:closed]
            !closed || (closed && include_closed)
          end
        end

        def option_parser(options=@options)
          OptionParser.new do |opts|
            opts.banner = "Usage: trello board [list]"

            opts.on("-c", "--closed", "Include closed board." ) do |o|
              @options[:closed] = o
            end
          end
        end

        def help
          puts option_parser.help
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trello_cli-0.3.0 lib/trello_cli/cli/board/list.rb
trello_cli-0.2.1 lib/trello_cli/cli/board/list.rb