lib/retrospec/cli.rb in retrospec-0.2.1 vs lib/retrospec/cli.rb in retrospec-0.3.0

- old
+ new

@@ -1,8 +1,9 @@ require_relative 'plugins' require 'trollop' require_relative '../retrospec' +require_relative 'config' module Retrospec class Cli include Retrospec::Plugins @@ -10,27 +11,29 @@ cli = Retrospec::Cli.new sub_commands = cli.plugin_map.keys cmd_help = sub_commands.join("\n") global_opts = Trollop::options do - version "0.1.0 (c) Corey Osman" + version "#{Retrospec::VERSION} (c) Corey Osman" banner <<-EOS A framework to automate your development workflow by generating common files and test patterns. Usage: retrospec [global options] subcommand [subcommand options] Available subcommands: #{cmd_help} EOS opt :module_path, "The path (relative or absolute) to the module directory" , :type => :string, :required => false, :default => File.expand_path('.') + opt :config_map, "The global retrospec config file", :type => :string, :required => false, :default => File.expand_path(File.join(ENV['HOME'], '.retrospec', 'config.yaml' )) 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 - cmd_opts = cli.plugin_map[cmd].send(:cli_options, global_opts) + # 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) else if global_opts[:available_plugins] Retrospec::Cli.list_available_plugins \ No newline at end of file