class Figobox::Cli

Public Instance Methods

set() click to toggle source
# File lib/figobox/cli.rb, line 12
    def set
      with_environments do |figaro_environment, nanobox_alias|
        parser = Figobox::ConfigParser.new
        variables = parser.get_keys_for_environment(figaro_environment)
        compiler = Figobox::CommandCompiler.new(nanobox_alias, variables)

        if options.dry_run?
          puts <<~OUTPUT
            Command to be executed:
              #{compiler.add}
          OUTPUT
        else
          command = compiler.add
          puts "Executing command:\n  #{command}"
          system command

          if nanobox_alias != "local" && nanobox_alias != "dry-run"
            puts
            puts "You will need to redeploy before these changes have any effect."
          end
        end
      end
    end

Private Instance Methods

default_nanobox_environment(figaro_environment) click to toggle source
# File lib/figobox/cli.rb, line 59
def default_nanobox_environment(figaro_environment)
  case figaro_environment.to_s.downcase
  when "development"
    "local"
  when "staging"
    "dry-run"
  when "production"
    ""
  end
end
with_environments() { |figaro_environment, nanobox_alias| ... } click to toggle source
# File lib/figobox/cli.rb, line 38
def with_environments
  figaro_environment = options.figaro_environment
  figaro_environment = nil if figaro_environment == "figaro_environment"

  unless figaro_environment
    abort "You must specify a figaro environment to use as a source"
    return
  end

  nanobox_alias = options.nanobox_alias
  nanobox_alias = nil if nanobox_alias == "nanobox_alias"
  nanobox_alias ||= default_nanobox_environment(figaro_environment)

  unless nanobox_alias
    abort "Unable to automatically determine the nanobox alias to use as a target. Please use the -n option to specify one."
    return
  end

  yield(figaro_environment, nanobox_alias)
end