Class: RubyCoded::Tools::CreateDirectoryTool
- Defined in:
- lib/ruby_coded/tools/create_directory_tool.rb
Overview
Create a directory (and any necessary parent directories) at the given path
Constant Summary
Constants inherited from BaseTool
BaseTool::CONFIRM_RISK, BaseTool::DANGEROUS_RISK, BaseTool::SAFE_RISK
Instance Method Summary collapse
Methods inherited from BaseTool
Constructor Details
This class inherits a constructor from RubyCoded::Tools::BaseTool
Instance Method Details
#execute(path:) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ruby_coded/tools/create_directory_tool.rb', line 17 def execute(path:) full_path = validate_path!(path) return full_path if full_path.is_a?(Hash) if File.exist?(full_path) return { error: "Path already exists: #{path}" } unless File.directory?(full_path) return "Directory already exists: #{path}" end FileUtils.mkdir_p(full_path) "Directory created: #{path}" rescue SystemCallError => e { error: "Failed to create directory #{path}: #{e.}" } end |