class Cased::CLI::Recorder
Constants
- KEY
- TRUE
Attributes
command[R]
events[R]
height[R]
options[R]
started_at[R]
width[R]
writer[RW]
Public Class Methods
new(command, env: {})
click to toggle source
# File lib/cased/cli/recorder.rb, line 24 def initialize(command, env: {}) @command = command @events = [] @width = Subprocess.check_output(%w[tput cols]).strip.to_i @height = Subprocess.check_output(%w[tput lines]).strip.to_i subprocess_env = ENV.to_h.dup subprocess_env[KEY] = TRUE subprocess_env.merge!(env) @writer = Cased::CLI::Asciinema::Writer.new( command: command, width: width, height: height, ) @options = { stdout: Subprocess::PIPE, env: subprocess_env, } end
recording?()
click to toggle source
@return [Boolean] if CLI
session is being recorded.
# File lib/cased/cli/recorder.rb, line 20 def self.recording? ENV[KEY] == TRUE end
Public Instance Methods
start()
click to toggle source
# File lib/cased/cli/recorder.rb, line 45 def start writer.time do Subprocess.check_call(command, options) do |t| t.communicate do |stdout, _stderr| STDOUT.write(stdout) writer << stdout.gsub("\n", "\r\n") end end end end