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.
226 227 228 229 230 231 232 233 234 |
# File 'lib/clacky/default_skills/onboard/scripts/import_external_skills.rb', line 226 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
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/clacky/default_skills/onboard/scripts/import_external_skills.rb', line 236 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 |