lib/cli.rb in trollolo-0.0.9 vs lib/cli.rb in trollolo-0.0.10

- old
+ new

@@ -72,11 +72,11 @@ def get_lists process_global_options options require_trello_credentials trello = TrelloWrapper.new(@@settings) - board = trello.board(options["board-id"]) + board = trello.board(board_id(options["board-id"])) lists = board.columns if @@settings.raw puts JSON.pretty_generate lists else @@ -91,11 +91,11 @@ def get_cards process_global_options options require_trello_credentials trello = TrelloWrapper.new(@@settings) - board = trello.board(options["board-id"]) + board = trello.board(board_id(options["board-id"])) cards = board.cards if @@settings.raw cards_as_json = [] cards.each do |card| @@ -116,11 +116,11 @@ def get_checklists process_global_options options require_trello_credentials trello = TrelloWrapper.new(@@settings) - board = trello.board(options["board-id"]) + board = trello.board(board_id(options["board-id"])) board.cards.each do |card| card.checklists.each do |checklist| puts checklist.name end end @@ -158,11 +158,11 @@ process_global_options options require_trello_credentials chart = BurndownChart.new @@settings puts "Preparing directory..." - chart.setup(options[:output],options["board-id"]) + chart.setup(options[:output],board_id(options["board-id"])) end desc "burndown", "Update burndown chart" option :output, :aliases => :o, :desc => "Output directory", :required => false option :new_sprint, :aliases => :n, :desc => "Create new sprint" @@ -201,11 +201,11 @@ def backup process_global_options options require_trello_credentials b = Backup.new @@settings - b.backup(options["board-id"]) + b.backup(board_id(options["board-id"])) end desc "list-backups", "List all backups" def list_backups b = Backup.new @@settings @@ -217,11 +217,11 @@ desc "show-backup", "Show backup of board" option "board-id", :desc => "Id of Trello board", :required => true option "show-descriptions", :desc => "Show descriptions of cards", :required => false, :type => :boolean def show_backup b = Backup.new @@settings - b.show(options["board-id"], options) + b.show(board_id(options["board-id"]), options) end desc "organization", "Show organization info" option "org-name", :desc => "Name of organization", :required => true def organization @@ -291,25 +291,10 @@ trello = TrelloWrapper.new(@@settings) trello.make_cover(options["card-id"], filename) end - desc "set-priorities", "Set priority text into card titles" - long_desc <<EOT - Add 'P<n>: ' to the beginning of every cards title, replace where - already present. n is the current position of the list on the card. -EOT - option "board-id", :desc => "Id of the board", :required => true - option "list-name", :desc => "Name of the list", :required => true - def set_priorities - process_global_options options - require_trello_credentials - - p = Prioritizer.new(@@settings) - p.prioritize(options["board-id"], options["list-name"]) - end - desc "list-member-boards", "List name and id of all boards" option "member-id", :desc => "Id of the member", :required => true def list_member_boards process_global_options options require_trello_credentials @@ -320,25 +305,72 @@ }.each { |board| puts "#{board["name"]} - #{board["id"]}" } end - desc "sprint-cleanup", "Move remaining cards to backlog" + desc "setup-scrum", "Create necessary elements of our SCRUM setup" + long_desc <<-EOT + Will create board, lists and labels with names as configured in trollolorc, + or use the defaults. + EOT + def setup_scrum + process_global_options options + require_trello_credentials + + c = Scrum::Creator.new(@@settings) + c.create + end + + desc "set-priorities", "Set priority text into card titles" long_desc <<EOT - After the sprint, move remaining cards from 'Sprint Backlog' and 'Doing' - back to the planning board into the 'Ready' list. + Add 'P<n>: ' to the beginning of every cards title in the 'Backlog' list, + replace where already present. n is the current position of the list on + the card. EOT option "board-id", :desc => "Id of the board", :required => true + option "backlog-list-name", :desc => "Name of backlog list", :required => false + def set_priorities + process_global_options options + require_trello_credentials + + p = Scrum::Prioritizer.new(@@settings) + p.prioritize(board_id(options["board-id"]), options["backlog-list-name"]) + end + + desc "cleanup-sprint", "Move remaining cards to the planning board" + long_desc <<EOT + After the sprint, move remaining cards from 'Sprint Backlog', 'Doing' + and 'QA' lists back to the planning board into the 'Ready' list. +EOT + option "board-id", :desc => "Id of the board", :required => true option "target-board-id", :desc => "Id of the target board", :required => true - def sprint_cleanup + def cleanup_sprint process_global_options options require_trello_credentials - s = SprintCleanup.new(@@settings) - s.cleanup(options["board-id"], options["target-board-id"]) + s = Scrum::SprintCleaner.new(@@settings) + s.cleanup(board_id(options["board-id"]), + board_id(options["target-board-id"])) end + desc "move-backlog", "Move the planning backlog to the sprint board" + long_desc <<-EOT + Two separate boards are used, a planning board and a sprint board for the + current sprint. + After each planning meeting the cards are moved from the planning boards + 'Backlog' list to the sprint boards 'Sprint Backlog' list. + EOT + option "planning-board-id", desc: "Id of the planning board", required: true + option "sprint-board-id", desc: "Id of the sprint board", required: true + def move_backlog + process_global_options options + require_trello_credentials + + m = Scrum::BacklogMover.new(@@settings) + m.move(board_id(options["planning-board-id"]), board_id(options["sprint-board-id"])) + end + private def process_global_options options @@settings.verbose = options[:verbose] @@settings.raw = options[:raw] @@ -365,7 +397,14 @@ if !@@settings.developer_public_key || !@@settings.member_token STDERR.puts "Require trello credentials in config file" exit 1 end + end + + # Returns the board_id using id_or_alias. If id_or_alias matches a mapping + # from trollolorc then the mapped id is returned or else the id_or_alias + # is returned. + def board_id(id_or_alias) + @@settings.board_aliases[id_or_alias] || id_or_alias end end