Class: Lutaml::Cli::Uml::SpaCommand
- Inherits:
-
Object
- Object
- Lutaml::Cli::Uml::SpaCommand
- Defined in:
- lib/lutaml/cli/uml/spa_command.rb
Overview
SpaCommand generates static SPA browser for UML models
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.add_options_to(thor_class, _method_name) ⇒ Object
rubocop:disable Metrics/MethodLength.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ SpaCommand
constructor
A new instance of SpaCommand.
-
#run(input_path) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
Constructor Details
#initialize(options = {}) ⇒ SpaCommand
Returns a new instance of SpaCommand.
13 14 15 |
# File 'lib/lutaml/cli/uml/spa_command.rb', line 13 def initialize( = {}) @options = .transform_keys(&:to_sym) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/lutaml/cli/uml/spa_command.rb', line 11 def @options end |
Class Method Details
.add_options_to(thor_class, _method_name) ⇒ Object
rubocop:disable Metrics/MethodLength
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/lutaml/cli/uml/spa_command.rb', line 17 def self.(thor_class, _method_name) # rubocop:disable Metrics/MethodLength thor_class.long_desc <<-DESC Generate a modern, interactive Single Page Application (SPA) for browsing UML models. Supports both single-file (all-in-one HTML) and multi-file (separate assets) output modes. Examples: # Single-file SPA (open directly in browser) lutaml uml build-spa model.lur -o browser.html # Multi-file site (for hosting) lutaml uml build-spa model.lur -o dist/ -m multi-file # With custom title and minification lutaml uml build-spa model.lur -o dist/ --title "My Model" --minify # From QEA file lutaml uml build-spa model.qea -o browser.html DESC thor_class.option :output, aliases: "-o", required: true, desc: "Output path (file for " \ "single-file, directory for " \ "multi-file)" thor_class.option :mode, aliases: "-m", default: "single-file", desc: "Output mode: 'single-file' or " \ "'multi-file'" thor_class.option :title, type: :string, default: "UML Model Browser", desc: "Site title" thor_class.option :minify, type: :boolean, default: false, desc: "Minify HTML/CSS/JS output" thor_class.option :theme, type: :string, default: "light", desc: "Default theme: 'light' or 'dark'" end |
Instance Method Details
#run(input_path) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/lutaml/cli/uml/spa_command.rb', line 52 def run(input_path) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength validate_input(input_path) mode = determine_mode output_path = validate_output_path(mode) OutputFormatter.progress("Loading repository from #{input_path}") repository = load_repository(input_path) OutputFormatter.progress_done OutputFormatter.progress("Generating SPA (#{mode} mode)") generate_spa(repository, mode, output_path) OutputFormatter.progress_done (mode, output_path) rescue StandardError => e OutputFormatter.progress_done(success: false) puts OutputFormatter.error("SPA generation failed: #{e.}") puts "Backtrace:" puts e.backtrace.first(20).join("\n") raise Thor::Error, "SPA generation failed: #{e.}" end |