<commit_before>require 'travis/cli'

module Travis
  module CLI
    class Show < RepoCommand
      def run(number = last_build.number)
        entity = job(number) || build(number)

        say template(__FILE__) % [
          entity.class.one.capitalize,
          entity.number,
          entity.commit.subject,
          entity.state,
          entity.color,
          entity.pull_request? ? "pull request" : "push",
          entity.commit.compare_url,
          formatter.duration(entity.duration),
          formatter.time(entity.started_at),
          formatter.time(entity.finished_at)
        ]

        if entity.respond_to? :jobs
          empty_line
          entity.jobs.each do |job|
            say [
              color("##{job.number} #{job.state}:".ljust(16), [job.color, :bold]),
              formatter.duration(job.duration).ljust(14),
              formatter.job_config(job.config),
              (color("(failure allowed)", :info) if job.allow_failures?)
            ].compact.join(" ")
          end
        else
          config = formatter.job_config(entity.config)
          say color("Allow Failure: ", :info) + entity.allow_failures?.inspect
          say color("Config:        ", :info) + config unless config.empty?
        end
      end
    end
  end
end

__END__

<[[ color("%s #%s: %s", :bold) ]]>
<[[ color("State:         ", :info) ]]><[[ color(%p, :%s) ]]>
<[[ color("Type:          ", :info) ]]>%s
<[[ color("Compare URL:   ", :info) ]]>%s
<[[ color("Duration:      ", :info) ]]>%s
<[[ color("Started:       ", :info) ]]>%s
<[[ color("Finished:      ", :info) ]]>%s<commit_msg>don't mess up empty env<commit_after>require 'travis/cli'

module Travis
  module CLI
    class Show < RepoCommand
      def run(number = last_build.number)
        entity = job(number) || build(number)

        say template(__FILE__) % [
          entity.class.one.capitalize,
          entity.number,
          entity.commit.subject,
          entity.state,
          entity.color,
          entity.pull_request? ? "pull request" : "push",
          entity.commit.compare_url,
          formatter.duration(entity.duration),
          formatter.time(entity.started_at),
          formatter.time(entity.finished_at)
        ]

        if entity.respond_to? :jobs
          empty_line
          entity.jobs.each do |job|
            say [
              color("##{job.number} #{job.state}:".ljust(16), [job.color, :bold]),
              formatter.duration(job.duration).ljust(14),
              formatter.job_config(job.config),
              (color("(failure allowed)", :info) if job.allow_failures?)
            ].compact.join(" ").rstrip
          end
        else
          config = formatter.job_config(entity.config)
          say color("Allow Failure: ", :info) + entity.allow_failures?.inspect
          say color("Config:        ", :info) + config unless config.empty?
        end
      end
    end
  end
end

__END__

<[[ color("%s #%s: %s", :bold) ]]>
<[[ color("State:         ", :info) ]]><[[ color(%p, :%s) ]]>
<[[ color("Type:          ", :info) ]]>%s
<[[ color("Compare URL:   ", :info) ]]>%s
<[[ color("Duration:      ", :info) ]]>%s
<[[ color("Started:       ", :info) ]]>%s
<[[ color("Finished:      ", :info) ]]>%s
{'fraction_non_alphanumeric': 0.1632275947028026, 'fraction_numerical': 0.0024638127502309825, 'mean_word_length': 2.081593927893738, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3269883', 'n_tokens_mistral': 1030, 'n_tokens_neox': 992, 'n_words': 194}