Class: Generators::Avo::SkillsInstallPanel
- Inherits:
-
Object
- Object
- Generators::Avo::SkillsInstallPanel
- Defined in:
- lib/generators/avo/skills_install_panel.rb
Overview
A small keyboard-driven panel for rails g avo:skills.
Two groups with different semantics: scope is a radio (this app OR the machine), targets are checkboxes (any combination of scan directories). Written against io/console from stdlib rather than a prompt gem, because avo is a dependency of other people's apps and a TUI is not worth adding one for.
Falls back to defaults whenever there is no interactive terminal, so
-q, CI, and piped invocations behave predictably. Callers pass explicit
flags to skip the panel entirely.
Defined Under Namespace
Classes: Result
Constant Summary collapse
- SCOPES =
[ {key: "local", label: "This app", hint: "committed, so the whole team gets it"}, {key: "global", label: "This machine", hint: "one install, every Avo project"} ].freeze
- TARGETS =
[ {key: "claude", label: ".claude/skills", hint: "Claude Code"}, {key: "agents", label: ".agents/skills", hint: "Codex, Gemini CLI, Goose, Amp, OpenCode"}, {key: "cursor", label: ".cursor/skills", hint: "Cursor"} ].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(input: $stdin, output: $stdout) ⇒ SkillsInstallPanel
constructor
A new instance of SkillsInstallPanel.
-
#rows ⇒ Object
Rows are the two scopes then the three targets, so one cursor walks both groups and the whole panel is arrow-navigable.
- #run ⇒ Object
Constructor Details
#initialize(input: $stdin, output: $stdout) ⇒ SkillsInstallPanel
Returns a new instance of SkillsInstallPanel.
36 37 38 39 40 41 42 43 |
# File 'lib/generators/avo/skills_install_panel.rb', line 36 def initialize(input: $stdin, output: $stdout) @input = input @output = output @scope = 0 @targets = TARGETS.map { |t| [t[:key], true] }.to_h @cursor = 0 @rows_drawn = 0 end |
Class Method Details
.interactive? ⇒ Boolean
32 33 34 |
# File 'lib/generators/avo/skills_install_panel.rb', line 32 def self.interactive? $stdin.tty? && $stdout.tty? end |
Instance Method Details
#rows ⇒ Object
Rows are the two scopes then the three targets, so one cursor walks both groups and the whole panel is arrow-navigable.
47 48 49 |
# File 'lib/generators/avo/skills_install_panel.rb', line 47 def rows SCOPES.length + TARGETS.length end |
#run ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/generators/avo/skills_install_panel.rb', line 51 def run render loop do case read_key when :up then move(-1) when :down then move(1) when :space then toggle when :enter then return finish when :cancel then return cancel end render end end |