Class: Lutaml::Cli::Uml::ReplCommand
- Inherits:
-
Object
- Object
- Lutaml::Cli::Uml::ReplCommand
- Defined in:
- lib/lutaml/cli/uml/repl_command.rb
Overview
ReplCommand starts interactive REPL shell
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ReplCommand
constructor
A new instance of ReplCommand.
-
#run(lur_path) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
Constructor Details
#initialize(options = {}) ⇒ ReplCommand
Returns a new instance of ReplCommand.
11 12 13 |
# File 'lib/lutaml/cli/uml/repl_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/repl_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 |
# File 'lib/lutaml/cli/uml/repl_command.rb', line 15 def self.(thor_class, _method_name) thor_class.long_desc <<-DESC Start an interactive REPL for exploring the model. Examples: lutaml uml repl model.lur lutaml uml repl model.lur --no-color DESC thor_class.option :color, type: :boolean, default: true, desc: "Enable colored output" thor_class.option :icons, type: :boolean, default: true, desc: "Enable icons in output" end |
Instance Method Details
#run(lur_path) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/lutaml/cli/uml/repl_command.rb', line 30 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 config = { color: [:color], icons: [:icons], } shell = InteractiveShell.new(lur_path, config: config) shell.start rescue StandardError => e puts OutputFormatter.error("Shell error: #{e.}") raise Thor::Error, "Shell error: #{e.}" end |