lib/cli.rb in trollolo-0.0.14 vs lib/cli.rb in trollolo-0.1.0

- old
+ new

@@ -48,10 +48,11 @@ evaluates to the access of https://api.trello.com/1/lists/53186e8391ef8671265eba9f/cards?filter=open&key=xxx&token=yyy EOT + def get_raw(url_fragment) process_global_options options require_trello_credentials url = "https://api.trello.com/1/#{url_fragment}" @@ -164,10 +165,11 @@ 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 @@ -178,11 +180,11 @@ require_trello_credentials chart = BurndownChart.new @@settings begin if options[:new_sprint] - chart.create_next_sprint(options[:output] || Dir.pwd, { total_days: options[:total_days], weekend_lines: options[:weekend_lines] }) + 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 @@ -203,12 +205,11 @@ option "board-id", :desc => "Id of Trello board", :required => true def backup process_global_options options require_trello_credentials - b = Backup.new @@settings - b.backup(board_id(options["board-id"])) + Backup.new(@@settings).backup(board_id(options["board-id"])) end desc "list-backups", "List all backups" def list_backups b = Backup.new @@settings @@ -219,26 +220,23 @@ 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(board_id(options["board-id"]), options) + 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 - trello = TrelloWrapper.new(@@settings) + organization = TrelloWrapper.new(@@settings).organization(options["org-name"]) - o = trello.organization(options["org-name"]) - - puts "Display Name: #{o.display_name}" - puts "Home page: #{o.url}" + 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 @@ -254,24 +252,22 @@ option "card-id", :desc => "Id of card", :required => true def set_description process_global_options options require_trello_credentials - trello = TrelloWrapper.new(@@settings) - trello.set_description(options["card-id"], STDIN.read) + 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 - members.sort! { |a, b| a.username <=> b.username } + members = trello.organization(options["org-name"]).members.sort_by(&:username) members.each do |member| puts "#{member.username} (#{member.full_name})" end end @@ -280,21 +276,19 @@ option "card-id", :desc => "Id of card", :required => true def set_cover(filename) process_global_options(options) require_trello_credentials - trello = TrelloWrapper.new(@@settings) - trello.add_attachment(options["card-id"], filename) + TrelloWrapper.new(@@settings).add_attachment(options["card-id"], filename) end desc "make-cover <filename>", "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 - trello = TrelloWrapper.new(@@settings) - trello.make_cover(options["card-id"], filename) + 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