Class: RosettAi::Thor::Tasks::Behaviour
- Inherits:
-
Thor
- Object
- Thor
- RosettAi::Thor::Tasks::Behaviour
- Defined in:
- lib/rosett_ai/thor/tasks/behaviour.rb
Overview
Behaviour configuration management tasks
Instance Method Summary collapse
Instance Method Details
#display ⇒ Object
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/rosett_ai/thor/tasks/behaviour.rb', line 281 def display behaviours = load_all_behaviours if behaviours.empty? puts Rainbow(t('no_files')).yellow return end sanitized = RosettAi::TextSanitizer.sanitize_for_display(behaviours) case [:format] when 'json' puts JSON.pretty_generate(sanitized) when 'yaml' puts sanitized.to_yaml else display_table(sanitized) end end |
#list ⇒ Object
309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/rosett_ai/thor/tasks/behaviour.rb', line 309 def list files = behaviour_files if files.empty? puts Rainbow(t('no_files_short')).yellow return end puts Rainbow(t('files_title')).bright files.each do |file| puts " #{Rainbow(File.basename(file, '.yml')).cyan}" end end |
#show(name) ⇒ Object
332 333 334 335 336 337 338 339 340 341 |
# File 'lib/rosett_ai/thor/tasks/behaviour.rb', line 332 def show(name) name = RosettAi::TextSanitizer.normalize_nfc(name) file_path = find_behaviour_file(name) raise ::Thor::Error, Rainbow(t('not_found', name: name)).red unless file_path content = RosettAi::YamlLoader.load_file(file_path) puts YAML.dump(RosettAi::TextSanitizer.sanitize_for_display(content)) rescue Psych::SyntaxError => e raise ::Thor::Error, Rainbow(t('yaml_syntax_error', path: file_path, detail: e.)).red end |
#validate(name = nil) ⇒ Object
356 357 358 359 360 361 362 363 |
# File 'lib/rosett_ai/thor/tasks/behaviour.rb', line 356 def validate(name = nil) name = RosettAi::TextSanitizer.normalize_nfc(name) if name files = files_to_validate(name) return puts Rainbow(t('no_validate')).yellow if files.empty? all_valid = validate_files(files) raise ::Thor::Error, t('validation_failed') unless all_valid end |