In Files

Parent

Namespace

Thor::Task

Public Class Methods

new(name, description, usage, options=nil) click to toggle source

(Not documented)

    # File lib/thor/task.rb, line 19
19:     def initialize(name, description, usage, options=nil)
20:       super(name.to_s, description, usage, options || {})
21:     end

Public Instance Methods

formatted_arguments(klass) click to toggle source

Injects the class arguments into the task usage.

    # File lib/thor/task.rb, line 64
64:     def formatted_arguments(klass)
65:       if klass && !klass.arguments.empty?
66:         usage.to_s.gsub(/^#{name}/) do |match|
67:           match << " " << klass.arguments.map{ |a| a.usage }.join(' ')
68:         end
69:       else
70:         usage.to_s
71:       end
72:     end
formatted_options() click to toggle source

Returns the options usage for this task.

    # File lib/thor/task.rb, line 76
76:     def formatted_options
77:       @formatted_options ||= options.map{ |_, o| o.usage }.sort.join(" ")
78:     end
formatted_usage(klass=nil, namespace=false, show_options=true) click to toggle source

Returns the formatted usage. If a class is given, the class arguments are injected in the usage.

    # File lib/thor/task.rb, line 47
47:     def formatted_usage(klass=nil, namespace=false, show_options=true)
48:       formatted = if namespace.is_a?(String)
49:         "#{namespace}:"
50:       elsif klass && namespace
51:         "#{klass.namespace.gsub(/^default/,'')}:"
52:       else
53:         ""
54:       end
55: 
56:       formatted << formatted_arguments(klass)
57:       formatted << " #{formatted_options}" if show_options
58:       formatted.strip!
59:       formatted
60:     end
run(instance, args=[]) click to toggle source

By default, a task invokes a method in the thor class. You can change this implementation to create custom tasks.

    # File lib/thor/task.rb, line 35
35:     def run(instance, args=[])
36:       raise UndefinedTaskError, "the '#{name}' task of #{instance.class} is private" unless public_method?(instance)
37:       instance.send(name, *args)
38:     rescue ArgumentError => e
39:       parse_argument_error(instance, e, caller)
40:     rescue NoMethodError => e
41:       parse_no_method_error(instance, e)
42:     end
short_description() click to toggle source

(Not documented)

    # File lib/thor/task.rb, line 28
28:     def short_description
29:       description.split("\n").first if description
30:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.