Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added Thor::Base.basename which is used by both Thor.banner and Thor:…

…:Group.banner.

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit d50594b07c54c57e566aad44f6b01125eb5765e8 1 parent 754299f
Postmodern postmodern authored josevalim committed
Showing with 9 additions and 3 deletions.
  1. +1 −2  lib/thor.rb
  2. +7 −0 lib/thor/base.rb
  3. +1 −1  lib/thor/group.rb
3  lib/thor.rb
View
@@ -252,8 +252,7 @@ def dispatch(meth, given_args, given_opts, config) #:nodoc:
# the namespace should be displayed as arguments.
#
def banner(task, namespace = nil, subcommand = false)
- base = File.basename($0).split(" ").first
- "#{base} #{task.formatted_usage(self, $thor_runner, subcommand)}"
+ "#{basename} #{task.formatted_usage(self, $thor_runner, subcommand)}"
end
def baseclass #:nodoc:
7 lib/thor/base.rb
View
@@ -531,6 +531,13 @@ def exit_on_failure?
false
end
+ #
+ # The basename of the program invoking the thor class.
+ #
+ def basename
+ File.basename($0).split(' ').first
+ end
+
# SIGNATURE: Sets the baseclass. This is where the superclass lookup
# finishes.
def baseclass #:nodoc:
2  lib/thor/group.rb
View
@@ -230,7 +230,7 @@ def dispatch(task, given_args, given_opts, config) #:nodoc:
# The banner for this class. You can customize it if you are invoking the
# thor class by another ways which is not the Thor::Runner.
def banner
- "#{$0} #{self_task.formatted_usage(self, false)}"
+ "#{basename} #{self_task.formatted_usage(self, false)}"
end
# Represents the whole class as a task.
Please sign in to comment.
Something went wrong with that request. Please try again.