Sha256: f81169dee66616c6ab2199dc813cd2ade4e557d9679343254f22cfc768bfcf0c

Contents?: true

Size: 909 Bytes

Versions: 1

Compression:

Stored size: 909 Bytes

Contents

require 'linecook/commands/command_error'
require 'configurable'

module Linecook
  module Commands
    class Command
      class << self
        def registry
          REGISTRY
        end
        
        def inherited(base)
          super
          registry[base.to_s.split('::').last.downcase] = base
        end
      end
      
      REGISTRY = {}
      
      extend Lazydoc::Attributes
      include Configurable
      
      lazy_attr :desc
      lazy_attr :args, :process
      lazy_register :process, Lazydoc::Arguments
      
      def initialize(config)
        initialize_config(config)
      end
      
      def log(action, msg)
        puts("      %s  %s" % [action, msg])
      end
      
      def sh(cmd)
        system cmd
      end
      
      def call(argv)
        process(*argv)
      end
      
      def process(*args)
        raise NotImplementedError
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
linecook-0.6.2 lib/linecook/commands/command.rb