Class: Bk::Commands::Annotations
- Defined in:
- lib/bk/commands/annotations.rb
Constant Summary collapse
- BuildAnnotationsQuery =
Client.parse <<-GRAPHQL query($slug: ID!) { build(slug: $slug) { number pipeline { slug } branch message url pullRequest { id } state startedAt finishedAt canceledAt annotations(first: 200) { edges { node { context style body { text } } } } } } GRAPHQL
Constants included from Format
Format::HORIZONTAL_PIPE, Format::VERTICAL_PIPE
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Methods included from Format
#annotation_colors, #build_colors, #build_header, #is_tty?, #job_colors, #pastel, #vertical_pipe
Methods included from Bk::Color
#colorize, #create_color_hash, #default_color, #error_color, #info_color, #success_color, #warning_color
Constructor Details
This class inherits a constructor from Bk::Commands::Base
Instance Method Details
#call(args: {}, url_or_slug: nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/bk/commands/annotations.rb', line 43 def call(args: {}, url_or_slug: nil) slug = determine_slug(url_or_slug) unless slug raise ArgumentError, "Unable to figure out slug to use" end result = query(BuildAnnotationsQuery, variables: {slug: slug}) build = result.data.build $stdout.puts build_header(build) $stdout.puts "" annotation_edges = build.annotations.edges annotations = annotation_edges.map { |edge| edge.node } format = AnnotationFormatter::Markdown.new # indent each annotation to separate it from the build status annotations.each_with_index do |annotation, index| $stdout.puts format.call(annotation) # horizontal separator between each unless index == annotations.length - 1 $stdout.puts "" $stdout.puts " #{HORIZONTAL_PIPE * (TTY::Screen.width - 4)} " $stdout.puts "" end end end |