diff options
author | Marc A. Paradise <marc.paradise@gmail.com> | 2021-02-16 15:50:24 -0500 |
---|---|---|
committer | Marc A. Paradise <marc.paradise@gmail.com> | 2021-02-16 15:51:26 -0500 |
commit | 3f23d3a9e065b0903eac507a9bc7ef6d0e14fc66 (patch) | |
tree | 0500a0d5a3169f2bd3fb968d286f3aa5b3ad9e6f | |
parent | 7eb9179ed6eaf024f62546001544ea2caa3d184c (diff) | |
download | chef-mp/experiment-direct-load.tar.gz |
Experimental: attempt to directly load known knife commandsmp/experiment-direct-load
Instead of loading all of them then searching, try to
load just the requested commanmd if we can find it by path.
Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
-rw-r--r-- | lib/chef/knife/acl_base.rb | 1 | ||||
-rw-r--r-- | lib/chef/knife/core/subcommand_loader.rb | 15 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/chef/knife/acl_base.rb b/lib/chef/knife/acl_base.rb index 0835d1ac05..d9a0a222c3 100644 --- a/lib/chef/knife/acl_base.rb +++ b/lib/chef/knife/acl_base.rb @@ -22,6 +22,7 @@ require_relative "../knife" class Chef class Knife module AclBase + Kernel.puts "LOADING ANYWAY HAHAHAH" PERM_TYPES = %w{create read update delete grant}.freeze unless defined? PERM_TYPES MEMBER_TYPES = %w{client group user}.freeze unless defined? MEMBER_TYPES diff --git a/lib/chef/knife/core/subcommand_loader.rb b/lib/chef/knife/core/subcommand_loader.rb index 26d7e0277c..6a67711d7f 100644 --- a/lib/chef/knife/core/subcommand_loader.rb +++ b/lib/chef/knife/core/subcommand_loader.rb @@ -111,7 +111,20 @@ class Chef load_commands end - def load_command(_command_args) + def load_command(command_args) + return true if @loaded + cmd_words = positional_arguments(command_args) + partial_path = "#{cmd_words.join("_")}.rb" + + # Take a best shot at loading the command before falling back to loading + # all commands. + subcommand_files.each do |file| + if file.end_with?(partial_path) + @loaded = true + Kernel.load file + end + end + # If we've set @loaded, this will noop load_commands end |