summaryrefslogtreecommitdiff
path: root/lib/chef/knife.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/knife.rb')
-rw-r--r--lib/chef/knife.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index 46e968827e..fed2ad4cfa 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -87,7 +87,16 @@ class Chef
def self.inherited(subclass)
unless subclass.unnamed?
subcommands[subclass.snake_case_name] = subclass
- subcommand_files[subclass.snake_case_name] += [caller[0].split(/:\d+/).first]
+ subcommand_files[subclass.snake_case_name] +=
+ if subclass.superclass.to_s == "Chef::ChefFS::Knife"
+ # ChefFS-based commands have a superclass that defines an
+ # inhereited method which calls super. This means that the
+ # top of the call stack is not the class definition for
+ # our subcommand. Try the second entry in the call stack.
+ [path_from_caller(caller[1])]
+ else
+ [path_from_caller(caller[0])]
+ end
end
end
@@ -221,6 +230,10 @@ class Chef
OFFICIAL_PLUGINS = %w[ec2 rackspace windows openstack terremark bluebox]
+ def self.path_from_caller(caller_line)
+ caller_line.split(/:\d+/).first
+ end
+
# :nodoc:
# Error out and print usage. probably because the arguments given by the
# user could not be resolved to a subcommand.