Sha256: 819ba7c3e52b44343a456fdcb2c3f7489aebe77c54b390491414a2273a466d0f

Contents?: true

Size: 864 Bytes

Versions: 1

Compression:

Stored size: 864 Bytes

Contents

require 'forwardable'

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

      def initialize(app)
        @app = app
      end

      def execute!
        check_command_exists_for_remove

        command.remove!
        display_success_msg
      end

      private

      def exists?
        commands.find { |c| c.name == name }
      end

      def display_success_msg
        puts "Successfully removed command '#{name}' from the current project!"
      end

      def check_command_exists_for_remove
        raise PGit::Error::User.new "Cannot remove a command that does not exist in the current project. See `pgit cmd add --help` if you want to add a new command" unless exists?
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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