Class: Archsight::CLI
- Inherits:
-
Thor
- Object
- Thor
- Archsight::CLI
- Defined in:
- lib/archsight/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #analyze ⇒ Object
- #console ⇒ Object
- #import ⇒ Object
- #lint ⇒ Object
- #template(kind = nil) ⇒ Object
- #version ⇒ Object
- #web ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
7 8 9 |
# File 'lib/archsight/cli.rb', line 7 def self.exit_on_failure? true end |
Instance Method Details
#analyze ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/archsight/cli.rb', line 157 def analyze configure_resources require "archsight/database" require "archsight/analysis" db = load_database_for_analysis analyses = filter_analyses(db) return puts("No analyses found#{" matching '#{[:filter]}'" if [:filter]}.") if analyses.empty? return print_analysis_dry_run(analyses) if [:dry_run] results = execute_analyses(db, analyses) print_analysis_results(results) exit 1 if results.any?(&:failed?) end |
#console ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/archsight/cli.rb', line 87 def console configure_resources require "archsight/database" require "irb" db = Archsight::Database.new(Archsight.resources_dir, verbose: true) db.reload! puts "Database loaded. Available: db" binding.irb end |
#import ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/archsight/cli.rb', line 104 def import configure_resources require "archsight/database" require "archsight/import/executor" resources_dir = Archsight.resources_dir # Load all handlers require_import_handlers # Create database that loads from resources directory # Only load Import resources to avoid validation errors on incomplete resources db = Archsight::Database.new(resources_dir, verbose: [:verbose], only_kinds: %w[Import BusinessActor], verify: false) if [:dry_run] puts "Execution Plan:" executor = Archsight::Import::Executor.new( database: db, resources_dir: resources_dir, verbose: true, filter: [:filter], force: [:force] ) executor.execution_plan else executor = Archsight::Import::Executor.new( database: db, resources_dir: resources_dir, verbose: [:verbose], filter: [:filter], force: [:force] ) executor.run! puts "All imports completed successfully." end rescue Archsight::Import::InterruptedError # Graceful shutdown already handled by executor exit 130 rescue Archsight::Import::DeadlockError => e puts "Error: #{e.}" exit 1 rescue Archsight::Import::ImportError => e puts "Error: #{e.}" exit 1 rescue Archsight::ResourceError => e display_error_with_context(e.to_s) exit 1 end |
#lint ⇒ Object
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 |
# File 'lib/archsight/cli.rb', line 48 def lint configure_resources require "archsight/database" require "archsight/linter" require "archsight/helpers" db = Archsight::Database.new(Archsight.resources_dir, compute_annotations: false, verbose: true) begin db.reload! rescue Archsight::ResourceError => e display_error_with_context(e.to_s) exit 1 end linter = Archsight::Linter.new(db) errors = linter.validate if errors.any? puts "Validation Errors (#{errors.count}):" errors.each { |error| display_error_with_context(error) } exit 1 end puts "All validations passed!" end |
#template(kind = nil) ⇒ Object
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/archsight/cli.rb', line 75 def template(kind = nil) require "archsight/template" require "archsight/resources" if kind.nil? list_kinds else puts Archsight::Template.generate(kind) end end |
#version ⇒ Object
174 175 176 |
# File 'lib/archsight/cli.rb', line 174 def version puts "archsight #{Archsight::VERSION}" end |
#web ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/archsight/cli.rb', line 27 def web configure_resources require "archsight/web/application" env = [:production] ? :production : :development Archsight::Web::Application.configure_environment!(env, logging: [:enable_logging]) Archsight::Web::Application.set :reload_enabled, ![:disable_reload] Archsight::Web::Application.set :inline_edit_enabled, [:inline_edit] restart_enabled = [:enable_restart] || ENV["ARCHSIGHT_RESTART_ENABLED"] == "true" restart_token = [:restart_token] || ENV.fetch("ARCHSIGHT_RESTART_TOKEN", nil) Archsight::Web::Application.set :restart_enabled, restart_enabled Archsight::Web::Application.set :restart_token, restart_token Archsight::Web::Application.setup_mcp! Archsight::Web::Application.run!(port: [:port], bind: [:host]) rescue Archsight::ResourceError => e display_error_with_context(e.to_s) exit 1 end |