Class: Lutaml::Cli::Uml::ServeCommand
- Inherits:
-
Object
- Object
- Lutaml::Cli::Uml::ServeCommand
- Defined in:
- lib/lutaml/cli/uml/serve_command.rb
Overview
ServeCommand starts interactive web UI
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ServeCommand
constructor
A new instance of ServeCommand.
-
#run(lur_path) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
Constructor Details
#initialize(options = {}) ⇒ ServeCommand
Returns a new instance of ServeCommand.
11 12 13 |
# File 'lib/lutaml/cli/uml/serve_command.rb', line 11 def initialize( = {}) @options = .transform_keys(&:to_sym) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/lutaml/cli/uml/serve_command.rb', line 9 def @options end |
Class Method Details
.add_options_to(thor_class, _method_name) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/lutaml/cli/uml/serve_command.rb', line 15 def self.(thor_class, _method_name) thor_class.long_desc <<-DESC Start a web server with an interactive UI for browsing the model. Uses the modern single-page application with JSON API and lunr.js search. Examples: lutaml uml serve model.lur lutaml uml serve model.lur --port 8080 DESC thor_class.option :port, aliases: "-p", type: :numeric, default: 3000, desc: "Port to listen on" thor_class.option :host, aliases: "-h", type: :string, default: "localhost", desc: "Host to bind to" end |
Instance Method Details
#run(lur_path) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/lutaml/cli/uml/serve_command.rb', line 33 def run(lur_path) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength unless File.exist?(lur_path) puts OutputFormatter.error("Package file not found: #{lur_path}") raise Thor::Error, "Package file not found: #{lur_path}" end puts OutputFormatter.colorize("\n=== Starting Web UI Server ===\n", :cyan) puts "Loading repository from: #{lur_path}" puts "Server will be available at: " \ "http://#{[:host]}:#{[:port]}" puts "\nPress Ctrl+C to stop the server\n\n" Lutaml::Xmi::WebUi::App.serve(lur_path, port: [:port], host: [:host]) rescue Interrupt puts "\n\n#{OutputFormatter.colorize('Server stopped', :yellow)}" rescue StandardError => e puts OutputFormatter.error("Server error: #{e.}") puts e.backtrace.first(5).join("\n") if [:verbose] raise Thor::Error, "Server error: #{e.}" end |