Class: Lutaml::Cli::Uml::StatsCommand
- Inherits:
-
Object
- Object
- Lutaml::Cli::Uml::StatsCommand
- Includes:
- SharedHelpers
- Defined in:
- lib/lutaml/cli/uml/stats_command.rb
Overview
StatsCommand shows repository statistics
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ StatsCommand
constructor
A new instance of StatsCommand.
-
#run(lur_path, _path = nil) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
Methods included from SharedHelpers
#load_repository, #normalize_path
Constructor Details
#initialize(options = {}) ⇒ StatsCommand
Returns a new instance of StatsCommand.
15 16 17 |
# File 'lib/lutaml/cli/uml/stats_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/stats_command.rb', line 13 def @options end |
Class Method Details
.add_options_to(thor_class, _method_name) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/lutaml/cli/uml/stats_command.rb', line 19 def self.(thor_class, _method_name) thor_class.long_desc <<-DESC Display statistics about the repository or a specific package. Examples: lutaml uml stats model.lur # Full repository stats lutaml uml stats model.lur --detailed # Detailed breakdown lutaml uml stats model.lur --type diagrams # Diagram-specific stats DESC thor_class.option :type, type: :string, default: "all", desc: "Statistics type " \ "(packages|classes|diagrams|all)" thor_class.option :detailed, type: :boolean, default: false, desc: "Show detailed statistics" thor_class.option :format, type: :string, default: "text", desc: "Output format (text|yaml|json)" 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/MethodLength
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/lutaml/cli/uml/stats_command.rb', line 40 def run(lur_path, _path = nil) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength repo = load_repository(lur_path, lazy: [:lazy]) statistics = repo.statistics if [:format] == "text" puts OutputFormatter.format_stats(statistics, detailed: [:detailed]) else puts OutputFormatter.format(statistics, format: [:format]) end rescue Thor::Error raise rescue ArgumentError => e raise Thor::Error, e. rescue StandardError => e raise Thor::Error, "Stats command failed: #{e.}" end |