Class: Belt::CLI::DoctorCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/belt/cli/doctor_command.rb

Constant Summary collapse

REQUIRED_TOOLS =
[
  { name: 'aws', check: %w[aws --version],
    install_url: 'https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html' },
  { name: 'terraform', check: %w[terraform --version],
    install_url: 'https://developer.hashicorp.com/terraform/install' },
  { name: 'ruby', check: %w[ruby --version], min_version: '3.3' },
  { name: 'bundler', check: %w[bundle --version], install_hint: 'gem install bundler' }
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verbose: false) ⇒ DoctorCommand

Returns a new instance of DoctorCommand.



41
42
43
44
45
# File 'lib/belt/cli/doctor_command.rb', line 41

def initialize(verbose: false)
  @verbose = verbose
  @issues = []
  @warnings = []
end

Class Method Details

.run(args) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/belt/cli/doctor_command.rb', line 18

def self.run(args)
  verbose = args.include?('--verbose') || args.include?('-v')

  if args.include?('--help') || args.include?('-h')
    puts usage
    exit 0
  end

  new(verbose: verbose).run
end

.usageObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/belt/cli/doctor_command.rb', line 29

def self.usage
  <<~USAGE
    Usage: belt doctor [options]

    Check system dependencies and AWS configuration for Belt.

    Options:
      -v, --verbose    Show detailed output for each check
      -h, --help       Show this help
  USAGE
end

Instance Method Details

#runObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/belt/cli/doctor_command.rb', line 47

def run
  puts "Belt Doctor\n"
  puts "Checking your system for Belt prerequisites...\n\n"

  check_tools
  check_aws_credentials
  check_aws_identity

  puts ''
  print_summary
end