Signed-off-by: Brice Figureau <brice-pup...@daysofwonder.com>
---
 lib/puppet/application/filebucket.rb |   27 ++++++++++++---------------
 spec/unit/application/filebucket.rb  |   11 +++++++++++
 2 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/lib/puppet/application/filebucket.rb 
b/lib/puppet/application/filebucket.rb
index 0ba7c41..f456e0d 100644
--- a/lib/puppet/application/filebucket.rb
+++ b/lib/puppet/application/filebucket.rb
@@ -2,20 +2,21 @@ require 'puppet'
 require 'puppet/application'
 require 'puppet/network/client'
 
-filebucket_options = [
-    [ "--bucket",   "-b",                      GetoptLong::REQUIRED_ARGUMENT ],
-    [ "--debug",       "-d",                   GetoptLong::NO_ARGUMENT ],
-    [ "--help",                "-h",                   GetoptLong::NO_ARGUMENT 
],
-    [ "--local",       "-l",                   GetoptLong::NO_ARGUMENT ],
-    [ "--remote",      "-r",                   GetoptLong::NO_ARGUMENT ],
-    [ "--verbose",  "-v",                      GetoptLong::NO_ARGUMENT ],
-    [ "--version",  "-V",           GetoptLong::NO_ARGUMENT ]
-]
-
-Puppet::Application.new(:filebucket, filebucket_options) do
+Puppet::Application.new(:filebucket) do
 
     should_not_parse_config
 
+    option("--version", "-V") do |arg|
+        puts "%s" % Puppet.version
+        exit
+    end
+
+    option("--bucket BUCKET","-b")
+    option("--debug","-d")
+    option("--local","-l")
+    option("--remote","-r")
+    option("--verbose","-v")
+
     dispatch do
         ARGV.shift
     end
@@ -88,8 +89,4 @@ Puppet::Application.new(:filebucket, filebucket_options) do
         end
     end
 
-    option(:version) do |arg|
-        puts "%s" % Puppet.version
-        exit
-    end
 end
\ No newline at end of file
diff --git a/spec/unit/application/filebucket.rb 
b/spec/unit/application/filebucket.rb
index d1ac82f..0050183 100644
--- a/spec/unit/application/filebucket.rb
+++ b/spec/unit/application/filebucket.rb
@@ -29,6 +29,17 @@ describe "Filebucket" do
         @filebucket.should respond_to(:handle_version)
     end
 
+    [:bucket, :debug, :help, :local, :remote, :verbose].each do |option|
+        it "should declare handle_#{option} method" do
+            @filebucket.should respond_to("handle_#{option}".to_sym)
+        end
+
+        it "should store argument value when calling handle_#{option}" do
+            @filebucket.options.expects(:[]=).with("#{option}".to_sym, 'arg')
+            @filebucket.send("handle_#{option}".to_sym, 'arg')
+        end
+    end
+
     it "should exit after printing the version" do
         @filebucket.stubs(:puts)
 
-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to