Class: UsePacks::Private::InteractiveCli::UseCases::Visualize

Inherits:
Object
  • Object
show all
Extended by:
T::Helpers, T::Sig
Includes:
Interface
Defined in:
lib/use_packs/private/interactive_cli/use_cases/visualize.rb

Instance Method Summary collapse

Methods included from Interface

all, included

Instance Method Details

#perform!(prompt) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/use_packs/private/interactive_cli/use_cases/visualize.rb', line 15

def perform!(prompt)
  teams_or_packs = prompt.select('Do you want the graph nodes to be teams or packs?', %w[Teams Packs])

  if teams_or_packs == 'Teams'
    teams = TeamSelector.multi_select(prompt)
    VisualizePackwerk.team_graph!(teams)
  else
    by_name_or_by_owner = prompt.select('Do you select packs by name or by owner?', ['By name', 'By owner'])
    if by_name_or_by_owner == 'By owner'
      teams = TeamSelector.multi_select(prompt)
      selected_packs = Packs.all.select do |p|
        teams.map(&:name).include?(CodeOwnership.for_package(p)&.name)
      end
    else
      selected_packs = PackSelector.single_or_all_pack_multi_select(prompt)
    end

    Private.visualize(packs: selected_packs)
  end
end

#user_facing_nameObject



37
38
39
# File 'lib/use_packs/private/interactive_cli/use_cases/visualize.rb', line 37

def user_facing_name
  'Visualize pack relationships'
end