Sha256: 21acd6f708e51da421b744da9b23f368ef489a058696e8953e0dd4ef130ab707

Contents?: true

Size: 975 Bytes

Versions: 1

Compression:

Stored size: 975 Bytes

Contents

require 'interactive'
module PGit
  class Project
    class Remove
      include Interactive

      attr_reader :project, :projects
      def initialize(app)
        @project = app.project
        @projects = app.projects

        raise PGit::Error::User, "#{@project.path} is not in the configuration file." unless @project.exists?
      end

      def execute!
        confirm.ask_and_wait_for_valid_response do |confirm_response|
          if confirm_response.yes?
            puts "Removing #{path} from the configuration file..."
            project.remove!
            puts "Removed."
          elsif confirm_response.no?
            puts "Cancelling..."
          end
        end
      end

      private

      def confirm
        Question.new do |c|
          c.question = "Are you sure you want to remove #{path} from the configuration file?"
          c.options = [:yes, :no]
        end
      end

      def path
        @project.path
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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