Class: Synthra::CLI::Commands::Live
- Inherits:
-
Object
- Object
- Synthra::CLI::Commands::Live
- Defined in:
- lib/synthra/cli/commands/live.rb
Overview
CLI command for live preview server
Constant Summary collapse
- DEFAULT_PORT =
4567- EXIT_SUCCESS =
0- EXIT_ERROR =
1
Instance Method Summary collapse
- #call(schema_dir, options) ⇒ Object
-
#initialize ⇒ Live
constructor
A new instance of Live.
- #start_live_server(schema_dir, port) ⇒ Object private
Constructor Details
#initialize ⇒ Live
Returns a new instance of Live.
16 17 18 |
# File 'lib/synthra/cli/commands/live.rb', line 16 def initialize # No args needed for this command end |
Instance Method Details
#call(schema_dir, options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/synthra/cli/commands/live.rb', line 20 def call(schema_dir, ) unless File.directory?(schema_dir) $stderr.puts "✗ Schema directory not found: #{schema_dir}" return EXIT_ERROR end port = [:port] || DEFAULT_PORT start_live_server(schema_dir, port) end |
#start_live_server(schema_dir, port) ⇒ Object (private)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/synthra/cli/commands/live.rb', line 33 def start_live_server(schema_dir, port) require_relative "../../live_preview" puts "🚀 Starting Synthra Live Preview..." puts "" puts " Schema directory: #{schema_dir}" puts " URL: http://localhost:#{port}" puts "" puts " Press Ctrl+C to stop" puts "" LivePreview.start(schema_dir: schema_dir, port: port) EXIT_SUCCESS rescue Errno::EADDRINUSE $stderr.puts "✗ Port #{port} is already in use. Try a different port with --port" EXIT_ERROR rescue StandardError => e $stderr.puts "✗ Failed to start server: #{e.}" EXIT_ERROR end |