Class: QueryGuard::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/query_guard/cli.rb,
lib/query_guard/cli/command.rb,
lib/query_guard/cli/formatter.rb,
lib/query_guard/cli/json_reporter.rb,
lib/query_guard/cli/commands/check.rb,
lib/query_guard/cli/commands/analyze.rb,
lib/query_guard/cli/batch_report_formatter.rb,
lib/query_guard/cli/paged_report_formatter.rb,
lib/query_guard/cli/source_metadata_collector.rb

Overview

Main CLI entry point handling command routing and argument parsing

Defined Under Namespace

Modules: Commands Classes: BatchReportFormatter, Command, Formatter, JsonReporter, PagedReportFormatter, SourceMetadataCollector

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CLI

Returns a new instance of CLI.



11
12
13
14
15
16
# File 'lib/query_guard/cli.rb', line 11

def initialize(args)
  @args = args
  @command = nil
  @options = {}
  @path = '.'
end

Class Method Details

.run(args) ⇒ Object



6
7
8
9
# File 'lib/query_guard/cli.rb', line 6

def self.run(args)
  cli = new(args)
  cli.execute
end

Instance Method Details

#execute ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/query_guard/cli.rb', line 18

def execute
  parse_arguments

  case @command
  when 'analyze'
    execute_analyze
  when 'check'
    execute_check
  when 'help', '--help', '-h', nil
    print_help
    exit 0
  when 'version', '--version', '-v'
    print_version
    exit 0
  else
    puts "Unknown command: #{@command}"
    print_help
    exit 1
  end
end