[PATCH aeolus-cli] BZ #795650: "This combination of parameters is not currently supported"

Jason Guiditta jguiditt at redhat.com
Tue Feb 21 18:29:02 UTC 2012


https://bugzilla.redhat.com/show_bug.cgi?id=795650

This was a documentation error.  As part of the fix, I added help
output on missing arguements.  This should make it clearer what is
missing, and we can add similar handling elsewhere, should this pop
up again.
---
 lib/aeolus_cli/command/build_command.rb |    3 +--
 lib/aeolus_cli/command/config_parser.rb |   12 +++++++++---
 man/aeolus-image-build.1                |    6 +++++-
 spec/command/build_command_spec.rb      |   18 ++++--------------
 4 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/lib/aeolus_cli/command/build_command.rb b/lib/aeolus_cli/command/build_command.rb
index 0741846..6945cfa 100644
--- a/lib/aeolus_cli/command/build_command.rb
+++ b/lib/aeolus_cli/command/build_command.rb
@@ -82,8 +82,7 @@ module Aeolus
 
       def combo_implemented?
         if @options[:template].empty? || @options[:target].empty? || @options[:environment].nil?
-          puts "Error: This combination of parameters is not currently supported"
-          quit(1)
+          raise ArgumentError, "Error: This combination of parameters is not currently supported"
         end
         true
       end
diff --git a/lib/aeolus_cli/command/config_parser.rb b/lib/aeolus_cli/command/config_parser.rb
index 2615161..1401870 100644
--- a/lib/aeolus_cli/command/config_parser.rb
+++ b/lib/aeolus_cli/command/config_parser.rb
@@ -40,7 +40,13 @@ module Aeolus
             puts opts
           else
             parse(opts)
-            self.send(@command.to_sym)
+	    begin
+              self.send(@command.to_sym)
+	    rescue ArgumentError => e
+	      puts "Warning, #{e.message}"
+	      puts opts
+	      exit(1)
+	    end
           end
         else
           puts generalOptions
@@ -152,8 +158,8 @@ module Aeolus
 
           opts.separator ""
           opts.separator "Examples:"
-          opts.separator "aeolus-image build --target ec2 --template my.tmpl        # build a new image for ec2 from based on the given template"
-          opts.separator "aeolus-image build --target ec2,rhevm --template my.tmpl  # build a new image for ec2 and for rhevm based on the given template"
+          opts.separator "aeolus-image build --target ec2 --template my.tmpl --environment default        # build a new image for ec2 from based on the given template for the default environment"
+          opts.separator "aeolus-image build --target ec2,rhevm --template my.tmpl --environment default  # build a new image for ec2 and for rhevm based on the given template for the default environment"
           #opts.separator "aeolus-image build --image $image_id                # (NOT IMPLEMENTED) rebuild the image template and targets from latest build"
           #opts.separator %q{aeolus-image build --target ec2,rackspace \         # rebuild the image with a new template and set of targets
           #         --image $image_i \
diff --git a/man/aeolus-image-build.1 b/man/aeolus-image-build.1
index 38cd210..0c8d1ad 100644
--- a/man/aeolus-image-build.1
+++ b/man/aeolus-image-build.1
@@ -2,7 +2,7 @@
 .SH NAME
 aeolus-image build \- command for building aeolus images
 .SH SYNOPSIS
-.B aeolus-image build [\-h|--help] [\-u|--username] [\-w|--password] [\-I|--image [image-id]] [\-e|--template [path-to-template]] [\-t|--targets [targets]] [\-d|--daemon]
+.B aeolus-image build [\-h|--help] [\-u|--username] [\-w|--password] [\-I|--image [image-id]] [\-e|--template [path-to-template]] [\-t|--targets [targets]] [\-E|--environment] [\-d|--daemon]
 .SH DESCRIPTION
 aeolus-image build command allows users to build new images based on a given TDL template file for a set of specified targets such e.g. EC2, RHEVM etc...  See list man list target-images for information on how to list the completed builds.
 .SH OPTIONS
@@ -19,6 +19,9 @@ Provide a list of targets for the build
 \-e, --template
 Provide path to a TDL template file for building against
 .TP
+\-E, --environment
+Limit image list to environment
+.TP
 \-d, --daemon
 Run as a background process
 .TP
@@ -30,6 +33,7 @@ Build a new image for ec2 based on the specified template TDL file template.tdl
 .B aeolus-image build
 \--targets ec2
 \--template ./template.tdl
+\--environment default
 .TP
 Martyn Taylor (mtaylor at redhat.com), Jason Guiditta (jguiditta at redhat.com)
 .SH SEE ALSO
diff --git a/spec/command/build_command_spec.rb b/spec/command/build_command_spec.rb
index c7ae408..f969aa4 100644
--- a/spec/command/build_command_spec.rb
+++ b/spec/command/build_command_spec.rb
@@ -74,17 +74,12 @@ module Aeolus
           end
         end
 
-        it "should exit with a message if only image id is provided" do
+        it "should raise an ArgumentError if only image id is provided" do
           @options.delete(:template)
           @options.delete(:target)
           @options[:image] = '825c94d1-1353-48ca-87b9-36f02e069a8d'
           b = BuildCommand.new(@options, @output)
-          begin
-            b.run
-          rescue SystemExit => e
-            e.status.should == 1
-          end
-          $stdout.string.should include("This combination of parameters is not currently supported")
+          lambda {b.run}.should raise_error(ArgumentError)
         end
 
         it "should exit with appropriate message when a non compliant template is given" do
@@ -101,16 +96,11 @@ module Aeolus
       end
 
       describe "#combo_implemented?" do
-        it "should give useful feedback if no template or target is specified" do
+        it "should raise an ArgumentError if required options are not specified" do
           @options[:template] = ''
           @options[:target] = []
           b = BuildCommand.new(@options, @output)
-          begin
-            b.combo_implemented?
-          rescue SystemExit => e
-            e.status.should == 1
-          end
-          $stdout.string.should include("This combination of parameters is not currently supported")
+	  lambda {b.combo_implemented?}.should raise_error(ArgumentError)
         end
       end
     end
-- 
1.7.7.6




More information about the aeolus-devel mailing list