Skip to content

Commit

Permalink
Update banner.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jan 18, 2010
1 parent 4853f31 commit c999a8d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 26 deletions.
8 changes: 3 additions & 5 deletions CHANGELOG.rdoc
@@ -1,9 +1,7 @@
== TODO

* Improve spec coverage for Thor::Runner

== 0.12, released 2009-11-06
== 0.12, released 2010-01-02

* Removed rr in favor to rspec mock framework
* Improved output for thor -T
* [#7] Do not force white color on status
* [#8] Yield a block with the filename on directory

Expand Down
1 change: 1 addition & 0 deletions bin/thor
Expand Up @@ -4,4 +4,5 @@
require 'thor'
require 'thor/runner'

$thor_runner = true
Thor::Runner.start
3 changes: 2 additions & 1 deletion lib/thor.rb
Expand Up @@ -193,7 +193,8 @@ def printable_tasks(all=true)
# the namespace should be displayed as arguments.
#
def banner(task)
"thor " + task.formatted_usage(self)
base = $thor_runner ? "thor" : File.basename($0.split(" ").first)
"#{base} #{task.formatted_usage(self, base == "thor")}"
end

def baseclass #:nodoc:
Expand Down
38 changes: 21 additions & 17 deletions lib/thor/group.rb
Expand Up @@ -224,7 +224,8 @@ def printable_tasks(*)
# thor class by another ways which is not the Thor::Runner.
#
def banner
"thor #{self_task.formatted_usage(self, false)}"
base = $thor_runner ? "thor" : File.basename($0.split(" ").first)
"#{base} #{self_task.formatted_usage(self, false)}"
end

# Represents the whole class as a task.
Expand All @@ -246,22 +247,25 @@ def create_task(meth) #:nodoc:

protected

# Shortcut to invoke with padding and block handling. Use internally by
# invoke and invoke_from_option class methods.
def _invoke_for_class_method(klass, task=nil, *args, &block) #:nodoc:
shell.padding += 1

result = if block_given?
if block.arity == 2
block.call(self, klass)
else
block.call(self, klass, task)
end
else
invoke klass, task, *args
# Shortcut to invoke with padding and block handling. Use internally by
# invoke and invoke_from_option class methods.
def _invoke_for_class_method(klass, task=nil, *args, &block) #:nodoc:
shell.padding += 1

result = if block_given?
case block.arity
when 3
block.call(self, klass, task)
when 2
block.call(self, klass)
when 1
instance_exec(klass, &block)
end

shell.padding -= 1
result
else
invoke klass, task, *args
end

shell.padding -= 1
result
end
end
4 changes: 2 additions & 2 deletions lib/thor/task.rb
Expand Up @@ -40,8 +40,8 @@ def run(instance, args=[])

# Returns the formatted usage by injecting given required arguments
# and required options into the given usage.
def formatted_usage(klass, namespace=nil)
namespace = klass.namespace if namespace.nil?
def formatted_usage(klass, namespace=true)
namespace = klass.namespace unless namespace == false

# Add namespace
formatted = if namespace
Expand Down
2 changes: 1 addition & 1 deletion lib/thor/version.rb
@@ -1,3 +1,3 @@
class Thor
VERSION = "0.12.2".freeze
VERSION = "0.12.3".freeze
end
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -8,6 +8,8 @@
require 'rdoc'
require 'diff/lcs' # You need diff/lcs installed to run specs (but not to run Thor).

$thor_runner = true

# Load fixtures
load File.join(File.dirname(__FILE__), "fixtures", "task.thor")
load File.join(File.dirname(__FILE__), "fixtures", "group.thor")
Expand Down

0 comments on commit c999a8d

Please sign in to comment.