Sha256: 93d2abd1b7fd0420d4cd12f6f65312024d9806ad8c4b4648bc40e8b0d8ec7643

Contents?: true

Size: 838 Bytes

Versions: 1

Compression:

Stored size: 838 Bytes

Contents

require 'forwardable'

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

      def initialize(app)
        @app = app
      end

      def execute!
        check_command_exists_for_update

        command.save!
        display_success_msg
      end

      private

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

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

      def check_command_exists_for_update
        raise PGit::Error::User.new "Cannot edit 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/edit.rb