Signed-off-by: Brice Figureau <brice-pup...@daysofwonder.com>
---
 lib/puppet/application/ralsh.rb |   25 +++++++++----------------
 spec/unit/application/ralsh.rb  |   12 ++++++++++++
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/lib/puppet/application/ralsh.rb b/lib/puppet/application/ralsh.rb
index a05533d..d15d3e6 100644
--- a/lib/puppet/application/ralsh.rb
+++ b/lib/puppet/application/ralsh.rb
@@ -1,17 +1,7 @@
 require 'puppet'
 require 'puppet/application'
 
-ralsh_options = [
-    [ "--debug",       "-d",   GetoptLong::NO_ARGUMENT ],
-    [ "--verbose",  "-v",   GetoptLong::NO_ARGUMENT ],
-    [ "--types",    "-t",   GetoptLong::NO_ARGUMENT ],
-    [ "--param",    "-p",   GetoptLong::REQUIRED_ARGUMENT ],
-    [ "--host",     "-H",   GetoptLong::REQUIRED_ARGUMENT ],
-    [ "--edit",     "-e",   GetoptLong::NO_ARGUMENT ],
-    [ "--help",     "-h",   GetoptLong::NO_ARGUMENT ]
-]
-
-Puppet::Application.new(:ralsh, ralsh_options) do
+Puppet::Application.new(:ralsh) do
 
     should_not_parse_config
 
@@ -22,11 +12,15 @@ Puppet::Application.new(:ralsh, ralsh_options) do
         @host = nil
     end
 
-    option(:host) do |arg|
+    option("--debug","-d")
+    option("--verbose","-v")
+    option("--edit","-e")
+
+    option("--host HOST","-H") do |arg|
         @host = arg
     end
 
-    option(:types) do |arg|
+    option("--types", "-t") do |arg|
         types = []
         Puppet::Type.loadall
         Puppet::Type.eachtype do |t|
@@ -37,7 +31,7 @@ Puppet::Application.new(:ralsh, ralsh_options) do
         exit
     end
 
-    option(:param) do |arg|
+    option("--param PARAM", "-p") do |arg|
         @extra_params << arg.to_sym
     end
 
@@ -169,5 +163,4 @@ Puppet::Application.new(:ralsh, ralsh_options) do
             Puppet::Util::Log.level = :info
         end
     end
-
-end
\ No newline at end of file
+end
diff --git a/spec/unit/application/ralsh.rb b/spec/unit/application/ralsh.rb
index 93a932d..8f39514 100644
--- a/spec/unit/application/ralsh.rb
+++ b/spec/unit/application/ralsh.rb
@@ -48,6 +48,18 @@ describe "ralsh" do
     end
 
     describe "when handling options" do
+
+        [:debug, :verbose, :edit].each do |option|
+            it "should declare handle_#{option} method" do
+                @ralsh.should respond_to("handle_#{option}".to_sym)
+            end
+
+            it "should store argument value when calling handle_#{option}" do
+                @ralsh.options.expects(:[]=).with(option, 'arg')
+                @ralsh.send("handle_#{option}".to_sym, 'arg')
+            end
+        end
+
         it "should set options[:host] to given host" do
             @ralsh.handle_host(:whatever)
 
-- 
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