Sha256: b388f57e276cb39453e4deb7faa84b686dcdfd9c226d6d21f4d06da4d712354b

Contents?: true

Size: 1.83 KB

Versions: 7

Compression:

Stored size: 1.83 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($0)} [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)
        return 0
      end

      def evaluate_recipe!(recipe)
        eval(recipe)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
depengine-3.0.20 lib/depengine/cli.rb
depengine-3.0.19 lib/depengine/cli.rb
depengine-3.0.18 lib/depengine/cli.rb
depengine-3.0.17 lib/depengine/cli.rb
depengine-3.0.16 lib/depengine/cli.rb
depengine-3.0.15 lib/depengine/cli.rb
depengine-3.0.14 lib/depengine/cli.rb