Module: Omnizip::Shared::HelpDispatch

Included in:
ArchiveCommands, Cli, ProfileCommands
Defined in:
lib/omnizip/cli.rb

Overview

Thor 1.x does not treat --help/-h on subcommands as a request for help: the flag reaches the command as a positional argument and arity checking fails. Classes extending this module route those flags to the standard help output instead.

Instance Method Summary collapse

Instance Method Details

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



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/omnizip/cli.rb', line 33

def dispatch(meth, given_args, given_opts, config)
  wants_help = [Array(given_args), Array(given_opts)].any? do |list|
    list.include?("--help") || list.include?("-h")
  end
  if wants_help
    name = meth || Array(given_args).grep_v(/\A-/).first
    # Subcommand groups intercept their own --help (e.g.
    # "archive create --help" must show the create usage).
    return super if subcommands.include?(name)

    return start(["help", name].compact, config)
  end

  super
end