lib/retrospec/cli.rb in retrospec-0.3.1 vs lib/retrospec/cli.rb in retrospec-0.4.0

- old
+ new

@@ -7,10 +7,11 @@ class Cli include Retrospec::Plugins def self.run cli = Retrospec::Cli.new + # get the list of plugins and provide the plugin name as sub commands sub_commands = cli.plugin_map.keys cmd_help = sub_commands.join("\n") global_opts = Trollop::options do version "#{Retrospec::VERSION} (c) Corey Osman" @@ -28,14 +29,15 @@ opt :available_plugins, "Show an online list of available plugins", :type => :boolean, :require => false, :short => '-a' stop_on sub_commands end cmd = ARGV.shift # get the subcommand if plugin_class = cli.plugin_map[cmd] - # run the subcommand options but first send the config file and global options to the subcomamnd - plugin_config = Retrospec::Config.plugin_context(Retrospec::Config.config_data(global_opts[:config_map]), cmd) - cmd_opts = cli.plugin_map[cmd].send(:cli_options, global_opts.merge(plugin_config)) - opts = global_opts.merge(cmd_opts) - Retrospec::Module.new(global_opts[:module_path], plugin_class, opts) + # this is what generates the cli options for the subcommand + # this is also the main entry point that runs the plugin's cli + global_config = Retrospec::Config.config_data(global_opts[:config_map]) + plugin_name = plugin_class.send(:plugin_name) + plugin_config = Retrospec::Config.plugin_context(global_config, plugin_name) + plugin_class.send(:run_cli, global_opts, global_config, plugin_config) else if global_opts[:available_plugins] Retrospec::Cli.list_available_plugins else # this is the default action when no command is entered \ No newline at end of file