Sha256: 0d9d069107d0ac33e738db71de56a2e5adf8954f616b9520fa227a1ab84bcc52

Contents?: true

Size: 1.86 KB

Versions: 3

Compression:

Stored size: 1.86 KB

Contents

module Depengine
  module CLI
    class << self
      def run(args, _input = $stdin, _output = $stdout, error = $stderr) #:nodoc:
        @deploy_home = '.'
        @recipe_name = 'recipe/deploy.rb'

        args_size = args.size

        args.options do |o|
          o.banner = "Usage: #{File.basename($PROGRAM_NAME)} [options]"
          o.separator ''
          o.on('-n', '--new [some_path]', 'create a new empty recipe directory structure') do |path|
            require_relative('helper/cli_helper')
            extend CLIHelper
            setup_new_recipe(path || '.')
          end
          o.on('-h', '--deployhome [DIRNAME]', 'Home of deployments.') do |dname|
            set :deploy_home, dname
          end
          o.on('-b', '--recipe-base-dir [DIRNAME]', 'Home of recipes. This takes precedence over --deployhome for recipe location.') do |dname|
            set :recipe_base_dir, dname
          end
          o.on('-r', '--recipe [FILENAME]', 'Filename of the recipe.') do |fname|
            @recipe_name = fname
          end
          o.on('-e', '--env [ENVNAME]', 'Environment name.') do |ename|
            set :env, ename
          end
          o.on('-t', '--maven_test_switch [SWITCH]', 'Disable mvn tests.') do |tname|
            set :maven_test_switch, tname
          end
          o.on('-v', '--version [VERSION]', 'Version.') do |vname|
            set :version, vname
          end
          o.parse!
        end
        unless args_size > 2
          error << args.options
          return 127
        end

        recipe_filename = File.join(($recipe_config[:recipe_base_dir] || $recipe_config[:deploy_home]), @recipe_name)
        puts "Evaluating recipe #{recipe_filename}"
        evaluate_recipe!(File.open(recipe_filename).read)
        0
      end

      def evaluate_recipe!(recipe)
        eval(recipe) # rubocop:disable Lint/Eval
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
depengine-3.0.23 lib/depengine/cli.rb
depengine-3.0.22 lib/depengine/cli.rb
depengine-3.0.21 lib/depengine/cli.rb