Class: UsePacks::Private::InteractiveCli::UseCases::Query

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

Overview

We have not yet pulled QueryPackwerk into open source, so we cannot include it in this CLI yet

Instance Method Summary collapse

Methods included from Interface

all, included

Instance Method Details

#perform!(prompt) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/use_packs/private/interactive_cli/use_cases/query.rb', line 21

def perform!(prompt)
  selection = prompt.select('For one pack or all packs?', ['One pack', 'All packs'])
  if selection == 'All packs'
    # Probably should just make `list_top_dependency_violations` take in an array of things
    # Better yet we might just want to replace these functions with `QueryPackwerk`
    selected_pack = nil
  else
    selected_pack = PackSelector.single_pack_select(prompt).name
  end

  limit = prompt.ask('Specify the limit of constants to analyze', default: 10, convert: :integer)

  selection = prompt.select('Are you interested in dependency or privacy violations?', %w[Dependency Privacy], default: 'Privacy')

  if selection == 'Dependency'
    UsePacks.list_top_dependency_violations(
      pack_name: selected_pack,
      limit: limit
    )
  else
    UsePacks.list_top_privacy_violations(
      pack_name: selected_pack,
      limit: limit
    )
  end
end

#user_facing_nameObject



16
17
18
# File 'lib/use_packs/private/interactive_cli/use_cases/query.rb', line 16

def user_facing_name
  'Query violations about a pack'
end