module Formatron::CLI::Deploy

CLI command for deploy

Public Instance Methods

deploy_action(c) click to toggle source
# File lib/formatron/cli/deploy.rb, line 34
def deploy_action(c)
  c.action do |args, options|
    directory = deploy_directory options
    target = deploy_target args[0], directory
    formatron = Formatron.new(
      credentials: deploy_credentials(options),
      directory: directory,
      target: target
    )
    formatron.deploy if deploy_ok options, formatron, target
  end
end
deploy_credentials(options) click to toggle source
# File lib/formatron/cli/deploy.rb, line 12
def deploy_credentials(options)
  options.credentials ||
    Generators::Credentials.default_credentials(
      deploy_directory(options)
    )
end
deploy_directory(options) click to toggle source
# File lib/formatron/cli/deploy.rb, line 8
def deploy_directory(options)
  options.directory || Dir.pwd
end
deploy_formatron_command() click to toggle source
# File lib/formatron/cli/deploy.rb, line 47
def deploy_formatron_command
  command :deploy do |c|
    c.syntax = 'formatron deploy [options] [TARGET]'
    c.summary = 'Deploy or update a Formatron stack'
    c.description = 'Deploy or update a Formatron stack'
    deploy_action c
  end
end
deploy_ok(options, formatron, target) click to toggle source
# File lib/formatron/cli/deploy.rb, line 26
def deploy_ok(options, formatron, target)
  options.yes || !formatron.protected? || agree(
    "Are you sure you wish to deploy protected target: #{target}?"
  ) do |q|
    q.default = 'no'
  end
end
deploy_target(target, directory) click to toggle source
# File lib/formatron/cli/deploy.rb, line 19
def deploy_target(target, directory)
  target || choose(
    'Target?',
    *Config.targets(directory: directory)
  )
end