lib/puppetry/cli.rb in puppetry_toolbox-0.0.3 vs lib/puppetry/cli.rb in puppetry_toolbox-0.0.4

- old
+ new

@@ -1,15 +1,16 @@ require 'thor' require 'grit' require 'fileutils' require 'puppetry/version' +require 'bundler' module Puppetry class CLI < Thor desc "version", "Print application's version" def version - puts "Puppetry v#{Puppetry::Version}" + output.puts "Puppetry v#{Puppetry::Version}" end desc "new NAME", "Create a new module called NAME" def new(name) Grit::Git.new(name).clone({}, "git://github.com/stefanozanella/puppet-skeleton", name) @@ -18,9 +19,27 @@ FileUtils.cd name do FileUtils.rm_rf File.expand_path('.git', '.') Bundler.with_clean_env do system "bundle install --path vendor/bundle" end + end + end + + no_commands do + ## + # Overrides the default output stream (`$stdout`) used by the + # application. Useful for testing. + # + # param output [IO] An IO object that will receive the CLI standard + # output + def output=(output) + @output = output + end + + private + + def output + @output || $stdout end end end end