Sha256: 06a1a986c0845a90f27110b197edeb5cdad4c06096a79ada74e3e75ac86d8799

Contents?: true

Size: 712 Bytes

Versions: 1

Compression:

Stored size: 712 Bytes

Contents

require 'forwardable'

module PGit
  class Command
    class Run
      extend Forwardable
      def_delegators :@app, :commands, :args, :global_opts, :opts, :current_project

      def initialize(app)
        @app = app
      end

      def execute!
        error_message = "Command '#{search}' does not exist. Run 'pgit cmd show' to see the available custom commands."
        raise PGit::Error::User, error_message unless command

        command.execute
      end

      private

      def search
        raise PGit::Error::User, "Run expects a command_name argument." if args.empty?
        args.first
      end

      def command
        commands.find {|c| c.name == args.first}
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pgit-1.0.0 lib/pgit/command/run.rb