Class: Ace::Demo::CLI::Commands::Record

Inherits:
Support::Cli::Command
  • Object
show all
Includes:
Support::Cli::Base
Defined in:
lib/ace/demo/cli/commands/record.rb

Instance Method Summary collapse

Instance Method Details

#call(tape:, args: [], **options) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ace/demo/cli/commands/record.rb', line 30

def call(tape:, args: [], **options)
  explicit_format = Atoms::RecordOptionValidator.normalize_format(
    options[:format],
    supported_formats: Organisms::DemoRecorder::SUPPORTED_FORMATS
  )
  backend = normalize_backend_option(options[:backend])
  options = options.dup
  options.delete(:format)
  options.delete(:backend)

  commands = collect_commands(args)

  if commands
    Atoms::RecordOptionValidator.validate_raw_tape_backend!(backend: backend)
    record_inline(name: tape, commands: commands, format: explicit_format || "gif", **options)
  else
    record_tape(tape: tape, format: explicit_format, backend: backend, **options)
  end
rescue TapeNotFoundError, VhsNotFoundError, VhsExecutionError, FfmpegNotFoundError, MediaRetimeError,
  PrNotFoundError, GhAuthenticationError, GhUploadError, GhCommentError, GhCommandError,
  AsciinemaNotFoundError, AsciinemaExecutionError, AggNotFoundError, AggExecutionError,
  ArgumentError, DemoYamlParseError => e
  raise Ace::Support::Cli::Error, e.message
end