Class: Packs::Private::InteractiveCli::UseCases::Query

Inherits:
Object
  • Object
show all
Extended by:
T::Helpers, T::Sig
Includes:
Interface
Defined in:
lib/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
# File 'lib/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_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, privacy, or layer violations?', %w[Dependency Privacy Layer], default: 'Privacy')

  Packs.list_top_violations(
    type: selection.downcase,
    pack_name: selected_pack,
    limit: limit
  )
end

#user_facing_nameObject



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

def user_facing_name
  'Query violations about a pack'
end