Module: UsePackwerk::Private::InteractiveCli

Extended by:
T::Sig
Defined in:
lib/use_packwerk/private/interactive_cli.rb,
lib/use_packwerk/private/interactive_cli/pack_selector.rb,
lib/use_packwerk/private/interactive_cli/team_selector.rb,
lib/use_packwerk/private/interactive_cli/use_cases/move.rb,
lib/use_packwerk/private/interactive_cli/use_cases/nest.rb,
lib/use_packwerk/private/interactive_cli/use_cases/check.rb,
lib/use_packwerk/private/interactive_cli/use_cases/query.rb,
lib/use_packwerk/private/interactive_cli/use_cases/create.rb,
lib/use_packwerk/private/interactive_cli/use_cases/rename.rb,
lib/use_packwerk/private/interactive_cli/use_cases/get_info.rb,
lib/use_packwerk/private/interactive_cli/use_cases/validate.rb,
lib/use_packwerk/private/interactive_cli/use_cases/interface.rb,
lib/use_packwerk/private/interactive_cli/use_cases/visualize.rb,
lib/use_packwerk/private/interactive_cli/use_cases/make_public.rb,
lib/use_packwerk/private/interactive_cli/use_cases/add_dependency.rb,
lib/use_packwerk/private/interactive_cli/use_cases/lint_package_yml.rb,
lib/use_packwerk/private/interactive_cli/use_cases/update_deprecations.rb,
lib/use_packwerk/private/interactive_cli/use_cases/regenerate_rubocop_todo.rb

Defined Under Namespace

Modules: UseCases Classes: PackSelector, TeamSelector

Class Method Summary collapse

Class Method Details

.start!(prompt: nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/use_packwerk/private/interactive_cli.rb', line 30

def self.start!(prompt: nil)
  prompt ||= TTY::Prompt.new(interrupt: lambda {
                                        puts "\n\nGoodbye! I hope you have a good day."
                                        exit 1 })
  help_text = '(Press ↑/↓ arrow to move, Enter to select and letters to filter)'
  choice = prompt.select('Hello! What would you like to do?',
    cycle: true,
    filter: true,
    help: help_text,
    show_help: :always,
    per_page: 15) do |menu|
    menu.enum '.'

    UseCases::Interface.all.each do |use_case|
      menu.choice use_case.user_facing_name, use_case
    end
  end

  choice.perform!(prompt)
end