Sha256: 154824dee552f733bb9b49240e7209a0102f6333310a2983f19b4eb76df2acff
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
#!/usr/bin/env ruby require 'open-uri' require 'json' BASE_URL = "https://www.pivotaltracker.com/services/v5/stories/" def get_story_info(story_id, flags = []) return nil if story_id.empty? begin include_owner_names = flags.any? { |f| f == '--owners' || f == '-O' } url = BASE_URL + "#{story_id}" + "/#{include_owner_names ? '?fields=:default,owners' : ''}" open( url, 'X-TrackerToken' => ENV['PIVOTAL_TRACKER_API_TOKEN'] ).read rescue StandardError => e JSON.generate({error: "could not get story info for story #{story_id}: #{e.message}\nstory info may be available at https://www.pivotaltracker.com/story/show/#{story_id}"}) end end flags = ARGV.reduce([]) do |reduced, a| reduced << a if a.include?('--') || a.include?('-') reduced end flags.each { |f| ARGV.delete f } stream = ARGV.any? ? ARGV : ARGF if stream == ARGF && $stdin.tty? puts "Usage:\nget-story-info-from-id STORY_ID\n" puts " OR\n" puts "echo STORY_ID | get-story-info-from-id" puts " OR\n" puts "use --w-owner-names to include owner names" exit 1 end infos = stream.reduce([]) do |reduced, story_id| next reduced unless story_id && story_id =~ /\d+/ reduced << get_story_info(story_id.strip, flags) end puts infos.join("\n")
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pivotoolz-1.1.1 | exe/get-story-info-from-id |
pivotoolz-1.1.0 | exe/get-story-info-from-id |