Class: Thor::Group

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/thor/group.rb

Instance Attribute Summary

Attributes included from Base

#options

Class Method Summary collapse

Methods included from Base

included, #initialize, register_klass_file, shell, shell=, subclass_files, subclasses

Class Method Details

.desc(description = nil) ⇒ Object

The descrition for this Thor::Group. If none is provided, but a source root exists, tries to find the USAGE one folder above it, otherwise searches in the superclass.

Parameters

description<String>

The description for this Thor::Group.



12
13
14
15
16
17
18
19
# File 'lib/thor/group.rb', line 12

def desc(description=nil)
  case description
    when nil
      @desc ||= from_superclass(:desc, nil)
    else
      @desc = description
  end
end

.help(shell, options = {}) ⇒ Object

Prints help information.

Options

short

When true, shows only usage.



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/thor/group.rb', line 41

def help(shell, options={})
  if options[:short]
    shell.say banner
  else
    shell.say "Usage:"
    shell.say "  #{banner}"
    shell.say
    class_options_help(shell)
    shell.say self.desc if self.desc
  end
end

.start(given_args = ARGV, config = {}) ⇒ Object

Start works differently in Thor::Group, it simply invokes all tasks inside the class.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/thor/group.rb', line 24

def start(given_args=ARGV, config={})
  super do
    if Thor::HELP_MAPPINGS.include?(given_args.first)
      help(config[:shell])
      return
    end

    args, opts = Thor::Options.split(given_args)
    new(args, opts, config).invoke
  end
end