Sha256: c854fed674c630cd69e150ae1a089868e0a5daf84645ab68a313bdf0ad4c0a73

Contents?: true

Size: 1006 Bytes

Versions: 1

Compression:

Stored size: 1006 Bytes

Contents

#!/usr/bin/env ruby

require 'json'
require 'ostruct'

environment_tag = ARGV[0]&.strip
if environment_tag.nil? || environment_tag.empty?
  puts "Usage: stories-deployed ENVIRONMENT"
  exit 1
end

flags = ARGV.select { |a| a.include?('--') || a.include?('-') }
deployed_story_infos = `story-ids-deployed #{environment_tag} | get-story-info-from-id #{flags.join(' ')}`

stories_deployed = deployed_story_infos.split("\n").compact.reduce([]) do |reduced, story_info|
  story = OpenStruct.new(JSON.parse(story_info))

  include_owner_names = flags.any? { |f| f == '--owners' || f == '-O' }

  reduced << "#{story.error}"
  reduced << "#{story.name&.strip}:\n#{story.url}"

  if include_owner_names
    owners = story
      .owners
      .compact
      .map { |o| OpenStruct.new(o).name }

    names_joined = owners.size > 2 ?
      "#{owners[0..-2].join(', ')} and #{owners.last}" :
      owners.join(' and ')

    reduced << "\nBrought to you by: #{names_joined}"
  end

  reduced
end

puts stories_deployed

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pivotoolz-1.1.1 exe/stories-deployed