Class: Lutaml::Xsd::Commands::MetadataCommand::GetCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Lutaml::Xsd::Commands::MetadataCommand::GetCommand
- Defined in:
- lib/lutaml/xsd/commands/metadata_command.rb
Overview
Get command implementation
Instance Attribute Summary
Attributes inherited from BaseCommand
Instance Method Summary collapse
-
#initialize(package_path, key, options) ⇒ GetCommand
constructor
A new instance of GetCommand.
- #run ⇒ Object
Constructor Details
#initialize(package_path, key, options) ⇒ GetCommand
Returns a new instance of GetCommand.
49 50 51 52 53 |
# File 'lib/lutaml/xsd/commands/metadata_command.rb', line 49 def initialize(package_path, key, ) super() @package_path = package_path @key = key end |
Instance Method Details
#run ⇒ Object
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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/lutaml/xsd/commands/metadata_command.rb', line 55 def run pkg = SchemaRepositoryPackage.new(@package_path) = pkg. # Load metadata if not already loaded unless validation = pkg.validate unless validation.valid? error "Failed to load package metadata" validation.errors.each { |err| error " - #{err}" } exit 1 end = validation. end # Filter out internal lutaml-model fields = .reject do |k, _| k.to_s.start_with?("_") || k == :using_default end # Show specific key or all if @key value = [@key.to_sym] || [@key] if value.nil? error "Metadata key '#{@key}' not found" exit 1 end output value.to_s elsif [:all] case [:format] when "json" require "json" output JSON.pretty_generate() when "yaml" require "yaml" output .to_yaml else # Text format - table () end else error "Please specify a KEY or use --all" exit 1 end rescue StandardError => e error "Failed to get metadata: #{e.}" verbose_output e.backtrace.join("\n") if verbose? exit 1 end |