Class: ExternalSkillsImportRunner
- Inherits:
-
Object
- Object
- ExternalSkillsImportRunner
- Defined in:
- lib/clacky/default_skills/onboard/scripts/import_external_skills.rb
Overview
Coordinator - runs all enabled importers and prints a combined report
Constant Summary collapse
- IMPORTERS =
Register new importer classes here to add support for more sources.
[OpenClawImporter].freeze
- SOURCES =
IMPORTERS.map { |klass| klass::SOURCE_NAME }.freeze
Instance Method Summary collapse
-
#initialize(sources: nil, target_skills_dir: File.join(Dir.home, '.clacky', 'skills'), dry_run: false, yes: false) ⇒ ExternalSkillsImportRunner
constructor
A new instance of ExternalSkillsImportRunner.
- #run ⇒ Object
Constructor Details
#initialize(sources: nil, target_skills_dir: File.join(Dir.home, '.clacky', 'skills'), dry_run: false, yes: false) ⇒ ExternalSkillsImportRunner
Returns a new instance of ExternalSkillsImportRunner.
268 269 270 271 272 273 274 275 276 |
# File 'lib/clacky/default_skills/onboard/scripts/import_external_skills.rb', line 268 def initialize(sources: nil, target_skills_dir: File.join(Dir.home, '.clacky', 'skills'), dry_run: false, yes: false) @sources = (sources || SOURCES) & SOURCES @target_skills_dir = Pathname.new(target_skills_dir). @dry_run = dry_run @yes = yes end |
Instance Method Details
#run ⇒ Object
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/clacky/default_skills/onboard/scripts/import_external_skills.rb', line 278 def run # In dry-run mode: collect plan and print preview only if @dry_run importers = build_importers(dry_run: true) all_imported = [] importers.each { |i| i.run; all_imported.concat(i.imported) } print_preview(all_imported, dry_run: true) return all_imported.size end # Normal mode: collect plan first, show preview, then confirm preview_importers = build_importers(dry_run: true) all_preview = [] preview_importers.each { |i| i.run; all_preview.concat(i.imported) } if all_preview.empty? puts 'Nothing to import.' return 0 end print_preview(all_preview, dry_run: false) unless @yes || confirm? puts 'Import cancelled.' return 0 end # Execute the actual import importers = build_importers(dry_run: false) all_imported = [] all_errors = [] importers.each do |importer| importer.run all_imported.concat(importer.imported) all_errors.concat(importer.errors) end print_summary(all_imported, all_errors) all_imported.size end |