Sha256: dcc5a46202e41c2d5017b2767bdf942194c1cc4ccd424bb83f5a2eae7ce84161
Contents?: true
Size: 2 KB
Versions: 2
Compression:
Stored size: 2 KB
Contents
require_relative 'plugins' require 'trollop' require_relative '../retrospec' module Retrospec class Cli include Retrospec::Plugins def self.run 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" 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 :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) 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 else # this is the default action when no command is entered # at a later time we will try and use some magic to guess # what the user wants Trollop.educate end end end def self.list_available_plugins Retrospec::Cli.new.available_plugins.each do |name, plugin_data| puts "#{name}: #{plugin_data['project_url']}" puts "\tDescription: #{plugin_data['description']}" puts "\tInstallation: gem install #{plugin_data['gem']} --no-rdoc --no-ri" end end def self.list_installed_plugins Retrospec::Cli.new.installed_plugins do |spec| puts "#{spec.name}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
retrospec-0.2.1 | lib/retrospec/cli.rb |
retrospec-0.2.0 | lib/retrospec/cli.rb |