Class: Lutaml::Cli::Uml::LsCommand
- Inherits:
-
Object
- Object
- Lutaml::Cli::Uml::LsCommand
- Includes:
- SharedHelpers
- Defined in:
- lib/lutaml/cli/uml/ls_command.rb
Overview
LsCommand lists elements in repository
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 = {}) ⇒ LsCommand
constructor
A new instance of LsCommand.
-
#run(lur_path, path = nil) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity.
Methods included from SharedHelpers
#load_repository, #normalize_path
Constructor Details
#initialize(options = {}) ⇒ LsCommand
Returns a new instance of LsCommand.
15 16 17 |
# File 'lib/lutaml/cli/uml/ls_command.rb', line 15 def initialize( = {}) @options = .transform_keys(&:to_sym) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/lutaml/cli/uml/ls_command.rb', line 13 def @options end |
Class Method Details
.add_options_to(thor_class, _method_name) ⇒ Object
rubocop:disable Metrics/MethodLength
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/lutaml/cli/uml/ls_command.rb', line 19 def self.(thor_class, _method_name) # rubocop:disable Metrics/MethodLength thor_class.long_desc <<-DESC List elements at the specified path in the repository. Examples: lutaml uml ls model.lur # List top-level packages lutaml uml ls model.lur ModelRoot::Core # List in Core package lutaml uml ls model.lur --type classes # List all classes lutaml uml ls model.lur --type diagrams # List all diagrams DESC thor_class.option :type, type: :string, default: "packages", desc: "Element type " \ "(packages|classes|diagrams|all)" thor_class.option :format, type: :string, default: "text", desc: "Output format " \ "(text|table|yaml|json)" thor_class.option :filter, type: :string, desc: "Filter pattern" thor_class.option :recursive, aliases: "-r", type: :boolean, default: false, desc: "Include nested elements" thor_class.option :lazy, type: :boolean, default: false, desc: "Use lazy loading" end |
Instance Method Details
#run(lur_path, path = nil) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/lutaml/cli/uml/ls_command.rb', line 44 def run(lur_path, path = nil) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity path = normalize_path(path) repo = load_repository(lur_path, lazy: [:lazy]) elements = case [:type].downcase when "packages" repo.list_packages(path, recursive: [:recursive]) when "classes" if path repo.classes_in_package(path, recursive: [:recursive]) else repo.all_classes end when "diagrams" # Use all_diagrams when no specific path is provided if path == "ModelRoot" repo.all_diagrams else repo.diagrams_in_package(path) end when "all" list_all_elements(repo, path) else puts OutputFormatter.error( "Unknown type: #{[:type]}", ) raise Thor::Error, "Unknown type: #{[:type]}" end if elements.empty? puts OutputFormatter.warning("No #{[:type]} found") return end display_element_list(elements, [:type]) rescue Thor::Error raise rescue ArgumentError => e raise Thor::Error, e. rescue StandardError => e raise Thor::Error, "List command failed: #{e.}" end |