Class: Belt::CLI::DoctorCommand
- Inherits:
-
Object
- Object
- Belt::CLI::DoctorCommand
- 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
-
#initialize(verbose: false, preflight: false) ⇒ DoctorCommand
constructor
A new instance of DoctorCommand.
-
#run ⇒ Object
rubocop:disable Naming/PredicateMethod.
- #run_full ⇒ Object
-
#run_preflight ⇒ Object
Returns true if all preflight checks pass, false otherwise.
Constructor Details
#initialize(verbose: false, preflight: false) ⇒ DoctorCommand
Returns a new instance of DoctorCommand.
44 45 46 47 48 49 |
# File 'lib/belt/cli/doctor_command.rb', line 44 def initialize(verbose: false, preflight: false) @verbose = verbose @preflight = preflight @issues = [] @warnings = [] end |
Class Method Details
.run(args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/belt/cli/doctor_command.rb', line 19 def self.run(args) verbose = args.include?('--verbose') || args.include?('-v') preflight = args.include?('--preflight') if args.include?('--help') || args.include?('-h') puts usage exit 0 end new(verbose: verbose, preflight: preflight).run end |
.usage ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/belt/cli/doctor_command.rb', line 31 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 --preflight Run only deploy-critical checks (indexes, credentials) -h, --help Show this help USAGE end |
Instance Method Details
#run ⇒ Object
rubocop:disable Naming/PredicateMethod
51 52 53 54 55 56 57 58 59 |
# File 'lib/belt/cli/doctor_command.rb', line 51 def run # rubocop:disable Naming/PredicateMethod if @preflight run_preflight else run_full end @issues.empty? end |
#run_full ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/belt/cli/doctor_command.rb', line 73 def run_full puts "Belt Doctor\n" puts "Checking your system for Belt prerequisites...\n\n" check_tools check_aws_credentials check_aws_identity check_table_indexes check_cognito_auth puts '' print_summary end |
#run_preflight ⇒ Object
Returns true if all preflight checks pass, false otherwise.
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/belt/cli/doctor_command.rb', line 62 def run_preflight check_aws_identity_quiet check_table_indexes check_cognito_auth return if @issues.empty? puts "\nPreflight checks failed:\n" @issues.each { |i| puts " ✗ #{i}" } puts '' end |