Class: Legion::TTY::Screens::Extensions
- Defined in:
- lib/legion/tty/screens/extensions.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- CORE =
%w[lex-node lex-tasker lex-scheduler lex-conditioner lex-transformer lex-synapse lex-health lex-log lex-ping lex-metering lex-llm-gateway lex-codegen lex-exec lex-lex lex-telemetry lex-audit lex-detect].freeze
- AI =
%w[lex-claude lex-openai lex-gemini].freeze
- SERVICE =
%w[lex-http lex-vault lex-github lex-consul lex-kerberos lex-tfe lex-redis lex-memcached lex-elasticsearch lex-s3].freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #activate ⇒ Object
- #discover_extensions ⇒ Object
- #handle_input(key) ⇒ Object
-
#initialize(app, output: $stdout) ⇒ Extensions
constructor
A new instance of Extensions.
- #render(_width, height) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(app, output: $stdout) ⇒ Extensions
Returns a new instance of Extensions.
20 21 22 23 24 25 26 |
# File 'lib/legion/tty/screens/extensions.rb', line 20 def initialize(app, output: $stdout) super(app) @output = output @gems = [] @selected = 0 @detail = false end |
Instance Method Details
#activate ⇒ Object
28 29 30 |
# File 'lib/legion/tty/screens/extensions.rb', line 28 def activate @gems = discover_extensions end |
#discover_extensions ⇒ Object
32 33 34 35 36 |
# File 'lib/legion/tty/screens/extensions.rb', line 32 def discover_extensions Gem::Specification.select { |s| s.name.start_with?('lex-') } .sort_by(&:name) .map { |s| build_entry(s) } end |
#handle_input(key) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/legion/tty/screens/extensions.rb', line 49 def handle_input(key) case key when :up @selected = [(@selected - 1), 0].max :handled when :down @selected = [(@selected + 1), @gems.size - 1].min :handled when :enter @detail = !@detail :handled when 'q', :escape if @detail @detail = false :handled else :pop_screen end else :pass end end |
#render(_width, height) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/legion/tty/screens/extensions.rb', line 38 def render(_width, height) lines = [Theme.c(:accent, ' LEX Extensions'), ''] lines += if @detail && @gems[@selected] detail_lines(@gems[@selected]) else list_lines(height - 4) end lines += ['', Theme.c(:muted, ' Enter=detail q=back')] pad_lines(lines, height) end |