Sha256: d9226c9d90dfcbb70c1414def14cc07f4f7737154a8312d39b3c744a55ca4f12

Contents?: true

Size: 840 Bytes

Versions: 17

Compression:

Stored size: 840 Bytes

Contents

# frozen_string_literal: true

name        'help'
usage       'help [command_name]'
summary     'show help'
description <<~DESC
  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.
DESC

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

17 entries across 17 versions & 1 rubygems

Version Path
cri-2.15.12 lib/cri/commands/basic_help.rb
cri-2.15.11 lib/cri/commands/basic_help.rb
cri-2.15.10 lib/cri/commands/basic_help.rb
cri-2.15.9 lib/cri/commands/basic_help.rb
cri-2.15.8 lib/cri/commands/basic_help.rb
cri-2.15.7 lib/cri/commands/basic_help.rb
cri-2.15.6 lib/cri/commands/basic_help.rb
cri-2.15.5 lib/cri/commands/basic_help.rb
cri-2.15.4 lib/cri/commands/basic_help.rb
cri-2.15.3 lib/cri/commands/basic_help.rb
cri-2.15.2 lib/cri/commands/basic_help.rb
cri-2.15.1 lib/cri/commands/basic_help.rb
cri-2.15.0 lib/cri/commands/basic_help.rb
cri-2.14.0 lib/cri/commands/basic_help.rb
cri-2.13.0 lib/cri/commands/basic_help.rb
cri-2.12.0 lib/cri/commands/basic_help.rb
cri-2.11.0 lib/cri/commands/basic_help.rb