Sha256: a42a06783c5c6c29e32d415c0a07d9ec33b31422669cd40bfedc7dd206de0d0a

Contents?: true

Size: 1.84 KB

Versions: 3

Compression:

Stored size: 1.84 KB

Contents

module Wukong
  module Deploy

    # A Runner class that implements wu-deploy.
    class DeployRunner < Wukong::Runner

      include Logging

      usage 'ACTION'

      description <<-EOF.gsub(/^ {8}/,'')
        wu-deploy is a tool for creating and interacting with deploy packs.

        You can create a new deploy pack

          $ wu-deploy new my_app

        The `--force' and `--skip' options can be used to control how conflict
        resolution works when creating files.  The `--dry_run` option can be
        used to see what happens without doing it.

        If you are within the directory of a deploy pack, you can enter an IRB
        console with the deploy pack's environment already loaded:

          $ wu-deploy console
      EOF

      # The action, or first argument given.
      #
      # @return [String]
      def action
        args.first
      end

      # The directory, or second argument given.
      #
      # @return [String]
      def directory
        args[1]
      end

      # Validate that the requested action is known and that its
      # arguments are valid.
      #
      # @return [true]
      # @raise [Wukong::Error] if the action or its arguments are invalid
      def validate
        case action
        when 'new'
          raise Error.new("Must provide a path to the root of the deploy pack you want to create") if directory.nil? || directory.blank?
        when 'console'
        else
          raise Error.new("Invalid action: <#{action}>.")
        end
        true
      end

      # Run the requested action.
      def run
        case action
        when 'new'
          require_relative('templater')
          Templater.new(File.expand_path(directory, Dir.pwd), settings).run!
        when 'console'
          require_relative('console')
          Wukong::Deploy::Console.new.run!
        end
      end
      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wukong-deploy-0.2.0 lib/wukong-deploy/deploy_runner.rb
wukong-deploy-0.1.1 lib/wukong-deploy/deploy_runner.rb
wukong-deploy-0.1.0 lib/wukong-deploy/deploy_runner.rb