Sha256: 11bf1125b2fcefcebead8fc0389b4b176c565ea7237da4ae52c64ac458793f90

Contents?: true

Size: 799 Bytes

Versions: 6

Compression:

Stored size: 799 Bytes

Contents

name        'help'
usage       'help [command_name]'
summary     'show help'
description <<-EOS
Show help for the given command, or show general help. When no command is
given, a list of available commands is displayed, as well as a list of global
command-line options. When a command is given, a command description, as well
as command-specific command-line options, are shown.
EOS

flag :v, :verbose, 'show more detailed help'

run do |opts, args, cmd|
  if cmd.supercommand.nil?
    raise NoHelpAvailableError,
          'No help available because the help command has no supercommand'
  end

  is_verbose = opts.fetch(:verbose, false)

  resolved_cmd = args.inject(cmd.supercommand) do |acc, name|
    acc.command_named(name)
  end
  puts resolved_cmd.help(verbose: is_verbose, io: $stdout)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cri-2.10.1 lib/cri/commands/basic_help.rb
cri-2.10.0 lib/cri/commands/basic_help.rb
cri-2.9.1 lib/cri/commands/basic_help.rb
cri-2.9.0 lib/cri/commands/basic_help.rb
cri-2.8.0 lib/cri/commands/basic_help.rb
cri-2.7.1 lib/cri/commands/basic_help.rb