Class: Hyraft::Rule::PortCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/hyraft/rule/engine/port_command.rb

Class Method Summary collapse

Class Method Details

.start(args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/hyraft/rule/engine/port_command.rb', line 8

def self.start(args)
  port_name = args[0]
  return show_usage unless port_name

  target_dir = args[1] || "."
  port_dir = File.join(target_dir, "engine/port")
  # Convert CamelCase to snake_case with underscore
  filename = port_name.gsub(/([a-z])([A-Z])/, '\1_\2').downcase + ".rb"
  full_path = File.join(port_dir, filename)

  FileUtils.mkdir_p(port_dir)
  File.write(full_path, port_template(port_name))

  puts "✓ Created port: #{full_path}"
end