module Troo module CLI class Show < ThorFixes package_name "show" desc "boards", "Show all the boards with lists." def boards boards = Troo::BoardRetrieval.all if boards.any? boards.map do |board| BoardPresenter.render_all(board) end else say "Boards not found." end end desc "board ()", "Show lists and cards for board (uses default board if not provided)." def board(board_id = nil) if board = Troo::BoardRetrieval.retrieve(board_id) if SetDefault.for(board) say "'#{board.name}' set to default." end BoardPresenter.render_show(board) else if board_id say "Board not found." else say "Specify a or use 'troo default board ' to set a default board first." end end end desc "list ()", "Show all cards for list (uses default list if not provided)." def list(list_id = nil) if list = Troo::ListRetrieval.retrieve(list_id) if SetDefault.for(list) say "'#{list.name}' set to default." end ListPresenter.render_show(list) else if list_id say "List not found." else say "Specify a or use 'troo default list ' to set a default list first." end end end desc "card ()", "Show a card including latest 3 comments for card (uses default card if not provided)." def card(card_id = nil) if card = Troo::CardRetrieval.retrieve(card_id) if SetDefault.for(card) say "'#{card.name}' set to default." end CardPresenter.render_show(card) else if card_id say "Card not found." else say "Specify a or use 'troo default card ' to set a default card first." end end end desc "comments ()", "Show all comments for card (uses default card if not provided)." def comments(card_id = nil) if card = Troo::CardRetrieval.retrieve(card_id) if SetDefault.for(card) say "'#{card.name}' set to default." end CommentPresenter.render_show(card) else if card_id say "Card not found." else say "Specify a or use 'troo default card ' to set a default card first." end end end end end end