Module: Formatron::CLI::Generators::Instance
- Defined in:
- lib/formatron/cli/generators/instance.rb
Overview
CLI command for instance generator
Instance Method Summary collapse
-
#instance_action(c) ⇒ Object
rubocop:disable Metrics/MethodLength.
- #instance_bootstrap_configuration(options) ⇒ Object
-
#instance_directory(options) ⇒ Object
rubocop:enable Metrics/MethodLength.
-
#instance_formatron_command ⇒ Object
rubocop:enable Metrics/MethodLength.
- #instance_instance_name(options, name) ⇒ Object
- #instance_name(options, directory) ⇒ Object
-
#instance_options(c) ⇒ Object
rubocop:disable Metrics/MethodLength.
- #instance_s3_bucket(options) ⇒ Object
- #instance_subnet(options) ⇒ Object
- #instance_targets(options) ⇒ Object
- #instance_vpc(options) ⇒ Object
Instance Method Details
#instance_action(c) ⇒ Object
rubocop:disable Metrics/MethodLength
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/formatron/cli/generators/instance.rb', line 87 def instance_action(c) c.action do |_args, | directory = instance_directory name = instance_name , directory Formatron::Generators::Instance.generate( directory, name: name, instance_name: instance_instance_name(, name), s3_bucket: instance_s3_bucket(), bootstrap_configuration: instance_bootstrap_configuration(), vpc: instance_vpc(), subnet: instance_subnet(), targets: instance_targets() ) end end |
#instance_bootstrap_configuration(options) ⇒ Object
63 64 65 66 |
# File 'lib/formatron/cli/generators/instance.rb', line 63 def instance_bootstrap_configuration() .bootstrap_configuration || ask('Bootstrap configuration? ') end |
#instance_directory(options) ⇒ Object
rubocop:enable Metrics/MethodLength
41 42 43 44 45 |
# File 'lib/formatron/cli/generators/instance.rb', line 41 def instance_directory() .directory || ask('Directory? ') do |q| q.default = Dir.pwd end end |
#instance_formatron_command ⇒ Object
rubocop:enable Metrics/MethodLength
106 107 108 109 110 111 112 113 114 |
# File 'lib/formatron/cli/generators/instance.rb', line 106 def instance_formatron_command command :'generate instance' do |c| c.syntax = 'formatron generate instance [options]' c.summary = 'Generate an instance configuration' c.description = 'Generate an instance configuration' c instance_action c end end |
#instance_instance_name(options, name) ⇒ Object
53 54 55 56 57 |
# File 'lib/formatron/cli/generators/instance.rb', line 53 def instance_instance_name(, name) .instance_name || ask('Instance Name? ') do |q| q.default = name end end |
#instance_name(options, directory) ⇒ Object
47 48 49 50 51 |
# File 'lib/formatron/cli/generators/instance.rb', line 47 def instance_name(, directory) .name || ask('Name? ') do |q| q.default = File.basename directory end end |
#instance_options(c) ⇒ Object
rubocop:disable Metrics/MethodLength
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/formatron/cli/generators/instance.rb', line 9 def (c) c.option '-n', '--name STRING', 'The name for the configuration' c.option '-i', '--instance-name STRING', 'The name for the instance' c.option( '-s', '--s3-bucket STRING', 'The S3 bucket to store encrypted configuration' ) c.option( '-b', '--bootstrap-configuration STRING', 'The name of the bootstrap configuration to depend on' ) c.option( '-p', '--vpc STRING', 'The name of the VPC to add the instance to' ) c.option( '-u', '--subnet STRING', 'The name of the subnet to add the instance to' ) c.option( '-x', '--targets LIST', Array, 'The targets (eg. production test)' ) end |
#instance_s3_bucket(options) ⇒ Object
59 60 61 |
# File 'lib/formatron/cli/generators/instance.rb', line 59 def instance_s3_bucket() .s3_bucket || ask('S3 Bucket? ') end |
#instance_subnet(options) ⇒ Object
74 75 76 77 78 |
# File 'lib/formatron/cli/generators/instance.rb', line 74 def instance_subnet() .subnet || ask('Subnet? ') do |q| q.default = 'private' end end |
#instance_targets(options) ⇒ Object
80 81 82 83 84 |
# File 'lib/formatron/cli/generators/instance.rb', line 80 def instance_targets() .targets || ask('Targets? ', Array) do |q| q.default = 'production test' end end |
#instance_vpc(options) ⇒ Object
68 69 70 71 72 |
# File 'lib/formatron/cli/generators/instance.rb', line 68 def instance_vpc() .vpc || ask('VPC? ') do |q| q.default = 'vpc' end end |