Sha256: 6d852438a1c2846dc4bbdd769882ce9956776ec8cccefaae9dae07cd2a615fc5

Contents?: true

Size: 1005 Bytes

Versions: 1

Compression:

Stored size: 1005 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.0 exe/stories-deployed