# Copyright (c) 2013-2014 SUSE LLC # # This program is free software; you can redistribute it and/or # modify it under the terms of version 3 of the GNU General Public License as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, contact SUSE LLC. # # To contact SUSE about this file by physical or electronic mail, # you may find current contact information at www.suse.com class Cli < Thor default_task :global class_option :version, type: :boolean, desc: 'Show version' class_option :verbose, type: :boolean, desc: 'Verbose mode' class_option :raw, type: :boolean, desc: 'Raw mode' class_option 'board-id', type: :string, desc: 'id of Trello board' def self.settings=(s) @@settings = s end desc 'global', 'Global options', hide: true def global if options[:version] puts "Trollolo: #{@@settings.version}" else Cli.help shell end end desc 'get-raw [URL-FRAGMENT]', 'Get raw JSON from Trello API' long_desc < destdir, plot: options[:plot]) end end desc 'burndown-init', 'Initialize burndown chart' option :output, aliases: :o, desc: 'Output directory', required: false option 'board-id', desc: 'Id of Trello board', required: true def burndown_init(command = nil) process_global_options options require_trello_credentials chart = BurndownChart.new @@settings puts 'Preparing directory...' chart.setup(options[:output] || Dir.pwd, 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' option :sprint_number, type: :numeric, desc: 'Provide the number of the sprint' option :total_days, type: :numeric, desc: 'Provide how many days the sprint longs. 10 days by default' option :weekend_lines, type: :array, desc: 'Set the weekend_lines. [3.5, 8.5] by default' option :plot, type: :boolean, desc: 'also plot the new data' option :plot_to_board, type: :boolean, desc: 'Send the plotted data to the board' option 'with-fast-lane', desc: 'Plot Fast Lane with new cards bars', required: false, type: :boolean option 'no-tasks', desc: 'Do not plot tasks line', required: false, type: :boolean option 'push-to-api', desc: 'Push collected data to api endpoint (in json)', required: false option 'board-id', desc: 'Id of Trello Board' def burndown process_global_options options require_trello_credentials chart = BurndownChart.new @@settings begin if options[:new_sprint] chart.create_next_sprint(options[:output] || Dir.pwd, options) end chart.update(options) puts "Updated data for sprint #{chart.sprint}" rescue TrolloloError => e STDERR.puts e exit 1 end end desc 'plot SPRINT-NUMBER [--output] [--no-tasks] [--with-fast-lane]', 'Plot burndown chart for given sprint' option :output, aliases: :o, desc: 'Output directory', required: false option 'with-fast-lane', desc: 'Plot Fast Lane with new cards bars', required: false, type: :boolean option 'no-tasks', desc: 'Do not plot tasks line', required: false, type: :boolean def plot(sprint_number) process_global_options options BurndownChart.plot(sprint_number, options) end desc 'backup', 'Create backup of board' option 'board-id', desc: 'Id of Trello board', required: true def backup process_global_options options require_trello_credentials Backup.new(@@settings).backup(board_id(options['board-id'])) end desc 'list-backups', 'List all backups' def list_backups b = Backup.new @@settings b.list.each do |backup| puts backup end end 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 Backup.new(@@settings).show(board_id(options['board-id']), options) end desc 'organization', 'Show organization info' option 'org-name', desc: 'Name of organization', required: true def organization process_global_options options require_trello_credentials organization = TrelloWrapper.new(@@settings).organization(options['org-name']) puts "Display Name: #{organization.display_name}" puts "Home page: #{organization.url}" end desc 'get-description', 'Reads description' option 'card-id', desc: 'Id of card', required: true def get_description process_global_options options require_trello_credentials trello = TrelloWrapper.new(@@settings) puts trello.get_description(options['card-id']) end desc 'set-description', 'Writes description read from standard input' option 'card-id', desc: 'Id of card', required: true def set_description process_global_options options require_trello_credentials TrelloWrapper.new(@@settings).set_description(options['card-id'], STDIN.read) end desc 'organization-members', 'Show organization members' option 'org-name', desc: 'Name of organization', required: true def organization_members process_global_options options require_trello_credentials trello = TrelloWrapper.new(@@settings) members = trello.organization(options['org-name']).members.sort_by(&:username) members.each do |member| puts "#{member.username} (#{member.full_name})" end end desc 'set-cover ', 'Set cover picture' option 'card-id', desc: 'Id of card', required: true def set_cover(filename) process_global_options(options) require_trello_credentials TrelloWrapper.new(@@settings).add_attachment(options['card-id'], filename) end desc 'make-cover ', 'Make existing picture the cover' option 'card-id', desc: 'Id of card', required: true def make_cover(filename) process_global_options(options) require_trello_credentials TrelloWrapper.new(@@settings).make_cover(options['card-id'], filename) 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 trello = TrelloWrapper.new(@@settings) trello.get_member_boards(options['member-id']).sort_by do |board| board['name'] end.each do |board| puts "#{board['name']} - #{board['id']}" end end 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 <: ' 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 <