Class: OmniAI::Tools::Disk::FileMoveTool

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/omniai/tools/disk/file_move_tool.rb

Overview

Examples:

tool = OmniAI::Tools::Disk::FileMoveTool.new(root: "./project")
tool.execute(
  old_path: "./README.txt",
  new_path: "./README.md",
)

Instance Method Summary collapse

Methods inherited from BaseTool

#initialize

Constructor Details

This class inherits a constructor from OmniAI::Tools::Disk::BaseTool

Instance Method Details

#execute(old_path:, new_path:) ⇒ String

Parameters:

  • old_path (String)
  • new_path (String)

Returns:

  • (String)


24
25
26
27
28
29
30
31
32
33
34
# File 'lib/omniai/tools/disk/file_move_tool.rb', line 24

def execute(old_path:, new_path:)
  @logger.info("#{self.class.name}#execute old_path=#{old_path.inspect} new_path=#{new_path.inspect}")

  FileUtils.mv(
    resolve!(path: old_path),
    resolve!(path: new_path)
  )
rescue SecurityError => e
  @logger.info("ERROR: #{e.message}")
  raise e
end