Method: Pipedream::Command.dispatch

Defined in:
lib/pipedream/command.rb

.dispatch(m, args, options, config) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/pipedream/command.rb', line 19

def dispatch(m, args, options, config)
  # Allow calling for help via:
  #   codepipe command help
  #   codepipe command -h
  #   codepipe command --help
  #   codepipe command -D
  #
  # as well thor's normal way:
  #
  #   codepipe help command
  help_flags = Thor::HELP_MAPPINGS + ["help"]
  if args.length > 1 && !(args & help_flags).empty?
    args -= help_flags
    args.insert(-2, "help")
  end

  #   codepipe version
  #   codepipe --version
  #   codepipe -v
  version_flags = ["--version", "-v"]
  if args.length == 1 && !(args & version_flags).empty?
    args = ["version"]
  end

  super
end