Skip to content

Commit

Permalink
Fix problem with help not including parent command names for subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
rleber committed Jun 18, 2011
1 parent 72417a6 commit 0523194
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/thor.rb
Expand Up @@ -199,9 +199,14 @@ def printable_tasks(all = true, subcommand = false)
def subcommands
@subcommands ||= from_superclass(:subcommands, [])
end

def parent_commands
@parent_commands ||= from_superclass(:parent_commands, [])
end

def subcommand(subcommand, subcommand_class)
self.subcommands << subcommand.to_s
subcommand_class.parent_commands << subcommand.to_s
subcommand_class.subcommand_help subcommand
define_method(subcommand) { |*args| invoke subcommand_class, args }
end
Expand Down
3 changes: 3 additions & 0 deletions lib/thor/task.rb
Expand Up @@ -39,6 +39,9 @@ def formatted_usage(klass, namespace = true, subcommand = false)

formatted ||= ""

# Add parent commands (for subcommands)
klass.parent_commands.each {|parent_command| formatted << parent_command + ' ' }

# Add usage with required arguments
formatted << if klass && !klass.arguments.empty?
usage.to_s.gsub(/^#{name}/) do |match|
Expand Down

0 comments on commit 0523194

Please sign in to comment.