Method: Status#progress

Defined in:
lib/doing/cli_status.rb

#progress(msg, idx, total, tail = []) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/doing/cli_status.rb', line 6

def progress(msg, idx, total, tail = [])
  status_width = format("> %s [%#{total.to_s.length}d/%d]: ", msg, 0, total).length
  max_width = cols - status_width
  if tail.is_a? Array
    tail.shift while tail.join(', ').length + 3 > max_width
    tail = tail.join(', ')
  end
  tail.ltrunc!(max_width)
  $stderr.print format("#{esc['kill']}#{esc['boldyellow']}> #{esc['boldgreen']}%s #{esc['white']}[#{esc['boldwhite']}%#{@commands.count.to_s.length}d#{esc['boldblack']}/#{esc['boldyellow']}%d#{esc['white']}]: #{esc['boldcyan']}%s#{esc['default']}\r", msg, idx, total, tail)
end