Module: Preek::DefaultCommand

Included in:
CLI
Defined in:
lib/preek/default_command.rb

Overview

Lets monkey patch to have a default action with arguments!

Instance Method Summary collapse

Instance Method Details

#dispatch(meth, given_args, given_opts, config) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/preek/default_command.rb', line 4

def dispatch(meth, given_args, given_opts, config)
  meth = retrieve_command_name(given_args)
  command = all_commands[normalize_command_name(meth)]
  unless command
    given_args.unshift meth
    meth = default_command
    command = all_commands[meth]
  end
  if given_args.empty? && command.name == default_command
    handle_argument_error(command, nil, given_args, nil)
  end
  super
end