Sha256: ed156120ce3c93ce9e2a5e40e935507111d6f00a0098fb4c4cb2224c499a8797

Contents?: true

Size: 1.04 KB

Versions: 14

Compression:

Stored size: 1.04 KB

Contents

class Thor
  class << self
    def before_hook(method, options = {})
      @hook = {} unless @hook
      @hook[method] = options
    end

    def hooks
      @hook
    end

    def send(*args)
      if args.first == :dispatch && !args[2].empty?
        running_task = args[2].first
        @hook.each do |method, options|
          if options[:only].include?(running_task.to_sym)
            new.send(method)
          end
        end
      end
      super
    end

    def start(given_args=ARGV, config={})
      config[:shell] ||= Thor::Base.shell.new
      send(:dispatch, nil, given_args.dup, nil, config)
    rescue Thor::Error => e
      ENV["THOR_DEBUG"] == "1" ? (raise e) : config[:shell].error(e.message)
      exit(1) if exit_on_failure?
    end

    # We overwrite this method so namespace is show
    # shelly *backup* restore FILENAME
    def handle_argument_error(task, error)
      raise InvocationError, "#{task.name.inspect} was called incorrectly. Call as #{self.banner(task, nil, self.to_s != 'Shelly::CLI::Main').inspect}."
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
shelly-0.1.21 lib/thor/thor.rb
shelly-0.1.21.pre lib/thor/thor.rb
shelly-0.1.20 lib/thor/thor.rb
shelly-0.1.19 lib/thor/thor.rb
shelly-0.1.18 lib/thor/thor.rb
shelly-0.1.17 lib/thor/thor.rb
shelly-0.1.16 lib/thor/thor.rb
shelly-0.1.15 lib/thor/thor.rb
shelly-0.1.14 lib/thor/thor.rb
shelly-0.1.13 lib/thor/thor.rb
shelly-0.1.12 lib/thor/thor.rb
shelly-0.1.11 lib/thor/thor.rb
shelly-0.1.10 lib/thor/thor.rb
shelly-0.1.9 lib/thor/thor.rb