Skip to content
Browse files

Workaround for bundler swallowing the '--verbose' flag

Recent bundlers swallow the --verbose flag (bundler/issues#2102): 'bundle exec knife ... -VV'  never does get the verbositoseness all the way to knife.

I'm preparing a patch for bundler, but being blind to backtraces is horrible enough however that a workaround here is justifiable.

If you specify '-Z' or '-ZZ' alone as an arg, it will be turned into '-V' or '-VV', resp.

I hate monkeying around with ARGV, but a) knife already does so, and b) after some poking around inside knife I don't see a clean way to do this. This only patches up 'knife cluster' commands (things that include Ironfan::KnifeCommon).
It also ignores any arguments that follow the string 'ssh' -- 'bundle exec knife -Z ssh awesomehood -Z' will be single verbose for knife and -Z for awesomehood.
  • Loading branch information...
1 parent 6c34fe3 commit 5c5144941c574db9d7f341a6098e960d3e4c24f0 Philip (flip) Kromer committed Sep 23, 2012
Showing with 13 additions and 0 deletions.
  1. +13 −0 lib/chef/knife/ironfan_knife_common.rb
View
13 lib/chef/knife/ironfan_knife_common.rb
@@ -203,6 +203,19 @@ def die *args
Ironfan.die(*args)
end
+ def parse_options(*)
+ workaround_bundler_issue_2102
+ super
+ end
+
+ # Work around a bug in bundler -- restores your ability to see backtraces
+ # (see https://github.com/infochimps-labs/ironfan/issues/166)
+ #
+ # Args of exactly '-Z' or '-ZZ' will be turned into '-V' and '-VV' resp.
+ def workaround_bundler_issue_2102
+ ARGV.each_with_index{|arg, idx| case arg when '-Z' then ARGV[idx] = '-V' when '-ZZ' then ARGV[idx] = '-VV' when 'ssh' then break ; end }
+ end
+
module ClassMethods
def sub_command
self.to_s.gsub(/^.*::/, '').gsub(/^Cluster/, '').downcase

0 comments on commit 5c51449

Please sign in to comment.
Something went wrong with that request. Please try again.