lib/cli.rb in trollolo-0.0.3 vs lib/cli.rb in trollolo-0.0.4
- old
+ new
@@ -35,10 +35,40 @@
else
Cli.help shell
end
end
+ desc "get-raw [URL-FRAGMENT]", "Get raw JSON from Trello API"
+ long_desc <<EOT
+Get raw JSON from Trello using the given URL fragment. Trollolo adds the server
+part and API version as well as the credentials from the Trollolo configuration.
+
+As example, the command
+
+ trollolo get-raw lists/53186e8391ef8671265eba9f/cards?filter=open
+
+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}"
+ if url_fragment =~ /\?/
+ url += "&"
+ else
+ url += "?"
+ end
+ url += "key=#{@@settings.developer_public_key}&token=#{@@settings.member_token}"
+ STDERR.puts "Calling #{url}"
+
+ response = Net::HTTP.get_response(URI.parse(url))
+ print JSON.pretty_generate(JSON.parse(response.body))
+ end
+
desc "get-lists", "Get lists"
option "board-id", :desc => "Id of Trello board", :required => true
def get_lists
process_global_options options
require_trello_credentials
@@ -160,26 +190,57 @@
burndown.fetch
puts "Story points:"
puts " Open: #{burndown.story_points.open}"
puts " Done: #{burndown.story_points.done}"
- puts " Total: #{burndown.story_points.total}"
+ puts " Total: #{burndown.story_points.total}"
+ puts
puts "Tasks:"
puts " Open: #{burndown.tasks.open}"
puts " Done: #{burndown.tasks.done}"
- puts " Total: #{burndown.tasks.total}"
+ puts " Total: #{burndown.tasks.total}"
puts
puts "Extra story points:"
puts " Open: #{burndown.extra_story_points.open}"
puts " Done: #{burndown.extra_story_points.done}"
- puts " Total: #{burndown.extra_story_points.total}"
+ puts " Total: #{burndown.extra_story_points.total}"
puts "Extra tasks:"
puts " Open: #{burndown.extra_tasks.open}"
puts " Done: #{burndown.extra_tasks.done}"
- puts " Total: #{burndown.extra_tasks.total}"
+ puts " Total: #{burndown.extra_tasks.total}"
+ puts
+ puts "FastLane Cards:"
+ puts " Open: #{burndown.fast_lane_cards.open}"
+ puts " Done: #{burndown.fast_lane_cards.done}"
+ puts " Total: #{burndown.fast_lane_cards.total}"
end
+ desc "burndowns", "run multiple burndowns"
+ option "board-list", :desc => "path to board-list.yaml", :required => true
+ option :plot, :type => :boolean, :desc => "also plot the new data"
+ option :output, :aliases => :o, :desc => "Output directory"
+ def burndowns
+ process_global_options options
+ board_list = YAML.load_file(options["board-list"])
+ board_list.keys.each do |name|
+ if name =~ /[^[:alnum:]. _]/ # sanitize
+ raise "invalid character in team name"
+ end
+ board = board_list[name]
+ if options['output']
+ destdir = File.join(options['output'], name)
+ else
+ destdir = name
+ end
+ chart = BurndownChart.new @@settings
+ if ! File.directory?(destdir)
+ chart.setup(destdir, board["boardid"])
+ end
+ chart.update({'output' => destdir, plot: options[:plot]})
+ end
+ end
+
desc "burndown-init", "Initialize burndown chart"
option :output, :aliases => :o, :desc => "Output directory", :required => true
option "board-id", :desc => "Id of Trello board", :required => true
def burndown_init command=nil
process_global_options options
@@ -191,31 +252,92 @@
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 :plot, :type => :boolean, :desc => "also plot the new data"
+ 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 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)
end
- chart.update(options[:output] || Dir.pwd)
+ chart.update(options)
+ puts "Updated data for sprint #{chart.sprint}"
rescue TrolloloError => e
STDERR.puts e
exit 1
end
end
-
- desc "plot", "Plot burndown chart"
+
+ 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
- plot_helper = File.expand_path("../../scripts/create_burndown.py", __FILE__ )
- system "python #{plot_helper} #{sprint_number}"
+ 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
+
+ b = Backup.new @@settings
+ b.backup(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
+ b = Backup.new @@settings
+ b.show(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)
+
+ o = trello.organization(options["org-name"])
+
+ puts "Display Name: #{o.display_name}"
+ puts "Home page: #{o.url}"
+ 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.each do |member|
+ puts "#{member.username} (#{member.full_name})"
+ end
end
private
def process_global_options options