class Brick::CLI::SubcommandLoader
Attributes
env[R]
Public Class Methods
new( env=ENV)
click to toggle source
# File lib/brick/cli/core/subcommand_loader.rb, line 9 def initialize( env=ENV) @env = env end
Public Instance Methods
find_subcommands_via_dirglob()
click to toggle source
# File lib/brick/cli/core/subcommand_loader.rb, line 25 def find_subcommands_via_dirglob # The "require paths" of the core knife subcommands bundled with chef files = Dir[File.expand_path('../../../cli/*.rb', __FILE__)] subcommand_files = {} files.each do |cli_file| rel_path = cli_file[/#{::Brick::BRICK_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/,1] subcommand_files[rel_path] = cli_file end subcommand_files end
load_commands()
click to toggle source
Load all the sub-commands
# File lib/brick/cli/core/subcommand_loader.rb, line 14 def load_commands subcommand_files.each { |subcommand| Kernel.load subcommand } true end
subcommand_files()
click to toggle source
# File lib/brick/cli/core/subcommand_loader.rb, line 21 def subcommand_files @subcommand_files ||= (find_subcommands_via_dirglob.values).flatten.uniq end