Class: Codeball::Commands::List

Inherits:
CommandKit::Commands::Command
  • Object
show all
Includes:
CommandKit::Colors, CommandKit::CombinedIO, CommandKit::Printing::Tables
Defined in:
lib/codeball/commands/list.rb

Overview

List files contained in a codeball.

Instance Method Summary collapse

Methods included from CommandKit::CombinedIO

included

Instance Method Details

#envObject



22
23
24
# File 'lib/codeball/commands/list.rb', line 22

def env
  (super || {}).merge("TERM" => "1")
end

#run(io) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/codeball/commands/list.rb', line 26

def run(io)
  input = io.read
  abort_if_empty(input)

  ball = Ball.parse(input)

  ball.each_warning { |msg| stderr.puts colors.yellow("warning: #{msg}") }

  rows = []
  ball.each_entry { |e| rows << [e.path, "#{e.line_count} lines"] }
  print_table_color(rows, header: %w[File Lines], color: :green, index: 0)
end