lib/vendorificator/cli.rb in vendorificator-0.5.git.v0.4.0.63.g8e9d54d vs lib/vendorificator/cli.rb in vendorificator-0.5.0

- old
+ new

@@ -13,11 +13,11 @@ require 'vendorificator' module Vendorificator class CLI < Thor VERBOSITY_LEVELS = {1 => :quiet, 2 => :default, 3 => :chatty, 9 => :debug} - attr_reader :environment + attr_reader :environment, :verbosity check_unknown_options! :except => [:git, :diff, :log] stop_on_unknown_option! :git, :diff, :log default_task :help @@ -31,22 +31,22 @@ def initialize(args = [], options = {}, config = {}) super parse_options - if self.options[:debug] + if verbosity >= 9 MiniGit.debug = true end if self.options[:version] say "Vendorificator #{Vendorificator::VERSION}" exit end @environment = Vendorificator::Environment.new( shell, - VERBOSITY_LEVELS[self.options[:verbose]] || :default, + VERBOSITY_LEVELS[verbosity] || :default, self.options[:file] ) class << shell # Make say_status always say it. @@ -58,27 +58,27 @@ desc :sync, "Download new or updated vendor files" method_option :update, :type => :boolean, :default => false def sync say_status 'DEPRECATED', 'Using vendor sync is deprecated and will be removed in future versions. Use vendor install or vendor update instead.', :yellow - environment.sync options.merge(:modules => modules) + environment.sync options.merge(:segments => modules) rescue DirtyRepoError fail! 'Repository is not clean.' rescue MissingVendorfileError fail! "Vendorfile not found. Vendorificator needs to run in the directory containing Vendorfile or config/vendor.rb." end desc :install, "Download and install new or updated vendor files" def install(*modules) - environment.sync options.merge(:modules => modules) + environment.sync options.merge(:segments => modules) rescue DirtyRepoError fail! 'Repository is not clean.' end desc :update, "Update installed vendor files" def update(*modules) - environment.sync options.merge(:modules => modules, :update => true) + environment.sync options.merge(:segments => modules, :update => true) rescue DirtyRepoError fail! 'Repository is not clean.' end desc "status", "List known vendor modules and their status" @@ -88,11 +88,11 @@ environment.load_vendorfile say_status 'DEPRECATED', 'Using vendor status is deprecated and will be removed in future versions', :yellow say_status 'WARNING', 'Git repository is not clean', :red unless environment.clean? - environment.each_vendor_instance(*modules) do |mod| + environment.each_segment(*modules) do |mod| status_line = mod.to_s updatable = mod.updatable? if updatable if updatable == true @@ -161,11 +161,11 @@ vendor git log my_module -- @MERGED@..HEAD -- @PATH@ # basic 'vendor log' vendor git diff module1 module2 -- --stat @MERGED@ -- @PATH@ # 'vendor diff', as diffstat EOF def git(command, *args) modules, git_options = split_git_options(args) - environment.each_vendor_instance(*modules) do |mod| + environment.each_segment(*modules) do |mod| unless mod.merged say_status 'unmerged', mod.to_s, :red next end @@ -230,12 +230,13 @@ if options[:version] say "Vendorificator #{Vendorificator::VERSION}" exit end - if options[:verbose] && (!VERBOSITY_LEVELS.keys.include? options[:verbose]) - fail! "Unknown verbosity level: #{options[:verbose].inspect}" - end + # figure out verbosity + @verbosity = self.options[:verbose].to_i + @verbosity = 2 if @verbosity.zero? + @verbosity = VERBOSITY_LEVELS.keys.select { |i| i < verbosity }.max unless VERBOSITY_LEVELS[@verbosity] end def split_git_options(args) case i = args.index('--') when nil then [args, []]