Module: Ace::Demo::Atoms::AsciinemaCommandBuilder

Defined in:
lib/ace/demo/atoms/asciinema_command_builder.rb

Class Method Summary collapse

Class Method Details

.build(output_path:, script_path: nil, shell_command: nil, tty_size: "80x24", cast_compatibility: :v2, asciinema_bin: "asciinema") ⇒ Object

cast_compatibility is accepted to keep the interface aligned with task requirements; v3 passthrough is currently the proven production path.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ace/demo/atoms/asciinema_command_builder.rb', line 13

def build(output_path:, script_path: nil, shell_command: nil, tty_size: "80x24", cast_compatibility: :v2, asciinema_bin: "asciinema")
  validate_cast_compatibility!(cast_compatibility)

  command = shell_command.to_s.strip
  if command.empty?
    escaped_script_path = Shellwords.escape(script_path.to_s)
    command = "bash #{escaped_script_path}"
  end

  cmd = [asciinema_bin, "rec", "--overwrite", "--command", command]
  cmd.concat(tty_size_flags(tty_size))
  cmd << output_path
  cmd
end