Signed-off-by: Brice Figureau <brice-pup...@daysofwonder.com> --- lib/puppet/application/puppet.rb | 52 ++++++++++++++++--------------------- spec/unit/application/puppet.rb | 11 ++++++++ 2 files changed, 34 insertions(+), 29 deletions(-)
diff --git a/lib/puppet/application/puppet.rb b/lib/puppet/application/puppet.rb index cace097..c8ca819 100644 --- a/lib/puppet/application/puppet.rb +++ b/lib/puppet/application/puppet.rb @@ -3,22 +3,31 @@ require 'puppet/application' require 'puppet/network/handler' require 'puppet/network/client' -puppet_options = [ - [ "--debug", "-d", GetoptLong::NO_ARGUMENT ], - [ "--help", "-h", GetoptLong::NO_ARGUMENT ], - [ "--logdest", "-l", GetoptLong::REQUIRED_ARGUMENT ], - [ "--execute", "-e", GetoptLong::REQUIRED_ARGUMENT ], - [ "--loadclasses", "-L", GetoptLong::NO_ARGUMENT ], - [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ], - [ "--use-nodes", GetoptLong::NO_ARGUMENT ], - [ "--detailed-exitcodes", GetoptLong::NO_ARGUMENT ], - [ "--version", "-V", GetoptLong::NO_ARGUMENT ] -] - -Puppet::Application.new(:puppet, puppet_options) do +Puppet::Application.new(:puppet) do should_parse_config + option("--debug","-d") + option("--execute EXECUTE","-e") + option("--loadclasses","-L") + option("--verbose","-v") + option("--use-nodes") + option("--detailed-exitcodes") + + option("--logdest LOGDEST", "-l") do |arg| + begin + Puppet::Util::Log.newdestination(arg) + options[:logset] = true + rescue => detail + $stderr.puts detail.to_s + end + end + + option("--version", "-V") do |arg| + puts "%s" % Puppet.version + exit + end + dispatch do return Puppet[:parseonly] ? :parseonly : :main end @@ -133,19 +142,4 @@ Puppet::Application.new(:puppet, puppet_options) do Puppet[:manifest] = ARGV.shift end end - - - option(:logdest) do |arg| - begin - Puppet::Util::Log.newdestination(arg) - options[:logset] = true - rescue => detail - $stderr.puts detail.to_s - end - end - - option(:version) do |arg| - puts "%s" % Puppet.version - exit - end -end \ No newline at end of file +end diff --git a/spec/unit/application/puppet.rb b/spec/unit/application/puppet.rb index cc5017f..3bad643 100644 --- a/spec/unit/application/puppet.rb +++ b/spec/unit/application/puppet.rb @@ -13,6 +13,17 @@ describe "Puppet" do @puppet.should respond_to(:handle_version) end + [:debug,:execute,:loadclasses,:verbose,:use_nodes,:detailed_exitcodes].each do |option| + it "should declare handle_#{option} method" do + @puppet.should respond_to("handle_#{option}".to_sym) + end + + it "should store argument value when calling handle_#{option}" do + @puppet.options.expects(:[]=).with(option, 'arg') + @puppet.send("handle_#{option}".to_sym, 'arg') + end + end + it "should ask Puppet::Application to parse Puppet configuration file" do @puppet.should_parse_config?.should be_true end -- 1.6.0.2 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en -~----------~----~----~----~------~----~------~--~---