Module: CodePicture::Cli::Commands::TakePicture

Extended by:
TakePicture
Included in:
TakePicture
Defined in:
lib/code_picture/cli/commands/take_picture.rb

Constant Summary collapse

Options =
Data.define(:input_file_path, :output_file_path, *CodePicture::Options.members) do
  def self.default = new(
    input_file_path: nil,
    output_file_path: "code-picture.html",
    **CodePicture::Options.default.to_h
  )
end

Instance Method Summary collapse

Instance Method Details

#call(options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/code_picture/cli/commands/take_picture.rb', line 15

def call(options)
  code_picture = take_picture(options)
  save_picture(code_picture, options.output_file_path)

  Result::Success.new(value: code_picture)
rescue Errno::ENOENT
  Result::Failure.new(error: "Couldn't find file `#{options.input_file_path}`")
rescue CodePicture::Theme::Error => error
  Result::Failure.new(error: error.message)
end