Module: Aptible::CLI::Subcommands::Config
- Included in:
- Agent
- Defined in:
- lib/aptible/cli/subcommands/config.rb
Class Method Summary collapse
-
.included(thor) ⇒ Object
rubocop:disable MethodLength rubocop:disable CyclomaticComplexity.
Class Method Details
.included(thor) ⇒ Object
rubocop:disable MethodLength rubocop:disable CyclomaticComplexity
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 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/aptible/cli/subcommands/config.rb', line 9 def self.included(thor) thor.class_eval do include Helpers::Operation include Helpers::App desc 'config', "Print an app's current configuration" option :app def config app = ensure_app() config = app.current_configuration env = config ? config.env : nil puts formatted_config(env || {}) end desc 'config:add', 'Add an ENV variable to an app' option :app define_method 'config:add' do |*args| # FIXME: define_method - ?! Seriously, WTF Thor. app = ensure_app() env = Hash[args.map { |arg| arg.split('=', 2) }] operation = app.create_operation(type: 'configure', env: env) poll_for_success(operation) end desc 'config:rm', 'Remove an ENV variable from an app' option :app define_method 'config:rm' do |*args| # FIXME: define_method - ?! Seriously, WTF Thor. app = ensure_app() env = Hash[args.map { |arg| [arg, ''] }] operation = app.create_operation(type: 'configure', env: env) poll_for_success(operation) end private def formatted_config(env) env.map { |k, v| "#{k}=#{Shellwords.escape(v)}" }.join("\n") end end end |