Permalink
Browse files

Merge pull request #35 from tapajos/verbose

Verbose mode
  • Loading branch information...
2 parents ee40dbb + 5a4af13 commit 16e8482bd7061652ccb1df31c769fdb3caadb5c9 @gabebw gabebw committed Sep 10, 2011
Showing with 20 additions and 8 deletions.
  1. +17 −5 lib/kumade/cli.rb
  2. +1 −1 lib/tasks/deploy.rake
  3. +2 −2 spec/kumade/cli_spec.rb
View
22 lib/kumade/cli.rb
@@ -16,13 +16,13 @@ def initialize(args = ARGV, out = StringIO.new)
parse_arguments!(args)
@environment = args.shift || 'staging'
- self.class.swapping_stdout_for(out, pretending?) do
+ self.class.swapping_stdout_for(out, print_output?) do
deploy
end
end
-
- def self.swapping_stdout_for(io, pretending = false)
- if pretending
+
+ def self.swapping_stdout_for(io, print_output = false)
+ if print_output
yield
else
begin
@@ -57,7 +57,11 @@ def parse_arguments!(args)
@options[:pretend] = p
end
- opts.on_tail('-v', '--version', 'Show version') do
+ opts.on_tail("-v", "--verbose", "Print what kumade is doing") do
+ @options[:verbose] = true
+ end
+
+ opts.on_tail('--version', 'Show version') do
puts "kumade #{Kumade::VERSION}"
exit
end
@@ -72,5 +76,13 @@ def parse_arguments!(args)
def pretending?
!!@options[:pretend]
end
+
+ def verbose?
+ @options[:verbose]
+ end
+
+ def print_output?
+ pretending? || verbose?
+ end
end
end
View
2 lib/tasks/deploy.rake
@@ -5,4 +5,4 @@ namespace :deploy do
Kumade::CLI.run([environment])
end
end
-end
+end
View
4 spec/kumade/cli_spec.rb
@@ -69,7 +69,7 @@
end
end
- context "in pretend mode" do
+ context "in print output mode" do
it 'prints everything' do
stdout.should_receive(:puts)
@@ -78,4 +78,4 @@
end
end
end
-end
+end

0 comments on commit 16e8482

Please sign in to comment.