Class: Lutaml::Cli::Uml::ExportCommand
- Inherits:
-
Object
- Object
- Lutaml::Cli::Uml::ExportCommand
- Defined in:
- lib/lutaml/cli/uml/export_command.rb
Overview
ExportCommand exports to structured formats
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ExportCommand
constructor
A new instance of ExportCommand.
-
#run(lur_path) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
Constructor Details
#initialize(options = {}) ⇒ ExportCommand
Returns a new instance of ExportCommand.
11 12 13 |
# File 'lib/lutaml/cli/uml/export_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/export_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/export_command.rb', line 15 def self.(thor_class, _method_name) thor_class.long_desc <<-DESC Export repository data to various formats. Examples: lutaml uml export model.lur --format json -o model.json lutaml uml export model.lur --format markdown -o docs/ DESC thor_class.option :format, type: :string, required: true, desc: "Export format (json|markdown)" thor_class.option :output, aliases: "-o", required: true, desc: "Output path" thor_class.option :package, type: :string, desc: "Filter by package" thor_class.option :recursive, type: :boolean, default: true, desc: "Include nested packages" 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 56 57 58 59 60 61 |
# File 'lib/lutaml/cli/uml/export_command.rb', line 33 def run(lur_path) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength repo = load_repository(lur_path) exporter_class = case [:format].downcase when "json" Lutaml::UmlRepository::Exporters::JsonExporter when "markdown" Lutaml::UmlRepository::Exporters::MarkdownExporter else puts OutputFormatter.error( "Unknown format: #{[:format]}", ) raise Thor::Error, "Unknown format: #{[:format]}" end exporter = exporter_class.new(repo) OutputFormatter.progress("Exporting to #{[:format]}") exporter.export([:output], .to_h.transform_keys(&:to_sym)) OutputFormatter.progress_done puts OutputFormatter.success("Exported to #{[:output]}") rescue StandardError => e OutputFormatter.progress_done(success: false) puts OutputFormatter.error("Export failed: #{e.}") raise Thor::Error, "Export failed: #{e.}" end |