Class: RosettAi::Thor::Tasks::License

Inherits:
Thor
  • Object
show all
Defined in:
lib/rosett_ai/thor/tasks/license.rb

Overview

Thor task for license key management.

License keys control access to premium content pack downloads — they NEVER restrict software functionality (GPL-3.0 compliance).

Instance Method Summary collapse

Instance Method Details

#activate(raw_key) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rosett_ai/thor/tasks/license.rb', line 34

def activate(raw_key)
  key = RosettAi::Licensing::LicenseKey.new(raw_key)
  key.decode

  store = RosettAi::Licensing::LicenseStore.new
  store.save(raw_key)

  puts Rainbow(t('activate.success', tier: key.tier.to_s)).green
rescue RosettAi::LicenseError => e
  raise ::Thor::Error, t('activate.invalid', reason: e.message)
end

#deactivateObject



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/rosett_ai/thor/tasks/license.rb', line 80

def deactivate
  store = RosettAi::Licensing::LicenseStore.new

  unless store.exists?
    puts Rainbow(t('deactivate.not_found')).yellow
    return
  end

  store.remove!
  puts Rainbow(t('deactivate.success')).green
end

#statusObject



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/rosett_ai/thor/tasks/license.rb', line 57

def status
  result = RosettAi::Licensing::LicenseValidator.new.validate

  if result[:tier].name == :community
    puts Rainbow(t('status.community')).yellow
    return
  end

  print_status_table(result)
  print_warnings(result[:warnings])
end