[Title] add multi argument value check
authorjiil.hyoun <jiil.hyoun@samsung.com>
Sat, 25 Aug 2012 08:40:48 +0000 (17:40 +0900)
committerjiil.hyoun <jiil.hyoun@samsung.com>
Sat, 25 Aug 2012 08:40:48 +0000 (17:40 +0900)
[Type] Enhancement
[Module] Toolchain /
[Priority] Minor
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I07c57ad89bef31c6862481ce886bd8770982606f

src/build_server/BuildClientOptionParser.rb
src/build_server/BuildServerOptionParser.rb
src/common/utils.rb
src/pkg_server/serverOptParser.rb

index b757465d95d9c81142766da0e889213cacde3603..005db890fd6f3b70c99c9b27dc7c0de5f260402d 100644 (file)
@@ -26,7 +26,9 @@ Contributors:
 - S-Core Co., Ltd
 =end
 
+$LOAD_PATH.unshift File.dirname(__FILE__)+"/src/common"
 require 'optparse'
+require 'utils'
 
 def option_error_check( options )
     case options[:cmd]
@@ -79,9 +81,12 @@ def option_error_check( options )
         raise ArgumentError, "Input is incorrect : #{options[:cmd]}"
     end
 
+       if ARGV.length > 1 then
+               raise ArgumentError, "Unknown argument value : #{ARGV[1]}"
+       end
 end
 
-def option_parse 
+def option_parse
     options = {}
     banner = "Requiest service to build-server command-line tool." + "\n" \
        + "\n" + "Usage: build-cli <SUBCOMMAND> [OPTS] or build-cli -h" + "\n" \
@@ -123,6 +128,10 @@ def option_parse
                
         options[:os] = nil
            opts.on( '-o', '--os <operating system>', 'target operating system: ubuntu-32/ubuntu-64/windows-32/windows-64/macos-64' ) do |os|
+                       if not Utils.multi_argument_test( os, "," ) then
+                               puts "OS variable parsing error : #{os}"
+                               exit
+                       end
             options[:os] = os
         end
 
index 6f496a7306f65e556c9da88251da63ea111e26b8..c641c222ce8cf44afb55214846c9172b842d4a52 100644 (file)
@@ -26,7 +26,9 @@ Contributors:
 - S-Core Co., Ltd
 =end
 
+$LOAD_PATH.unshift File.dirname(__FILE__)+"/src/common"
 require 'optparse'
+require 'utils'
 
 def option_error_check( options )
     case options[:cmd]
@@ -147,7 +149,11 @@ def option_parse
         end
 
         options[:os] = nil
-               opts.on( '-o', '--os <target os list>', 'ex) linux,windows' ) do|os|
+               opts.on( '-o', '--os <target os list>', 'ex) linux-32,windows-32' ) do|os|
+                       if not Utils.multi_argument_test( os, "," ) then
+                               puts "OS variable parsing error : #{os}"
+                               exit
+                       end
             options[:os] = os
         end
 
index a71f2928af35d8404941c4aa3631a8c5efc74aa3..377641c5172bf7b4d78cf06a212f002eedc096bc 100644 (file)
@@ -433,6 +433,10 @@ class Utils
                return nil
        end
 
+       def Utils.multi_argument_test( arg, seperator )
+               return ( not arg.end_with? seperator and not arg.split( seperator ).select{|x| x.empty?}.length > 0 )
+       end
+
 
        if defined?(HOST_OS).nil? then
                HOST_OS = Utils.identify_current_OS()
index 753ea89db25b6772c763d0cff652dc64e511644b..15904668a69da24fde0cd6795c8b0d5280a5944d 100644 (file)
@@ -163,6 +163,10 @@ def option_parse
         end
                
                opts.on( '-P', '--pkgs <package file list>', 'package file path list' ) do|pkgs|
+                       if not Utils.multi_argument_test( pkgs, "," ) then
+                               puts "Package variable parsing error : #{pkgs}"
+                               exit
+                       end
             list = pkgs.tr(" \t","").split(",")
             list.each do |l|
                                if l.start_with? "~" then l = Utils::HOME + l.delete("~") end
@@ -171,6 +175,10 @@ def option_parse
         end
                
                opts.on( '-s', '--snapshot <snapshot>', 'a snapshot name or snapshot list' ) do|snaplist|
+                       if not Utils.multi_argument_test( snaplist, "," ) then
+                               puts "Snapshot variable parsing error : #{snaplist}"
+                               exit
+                       end
             options[:snaps] = snaplist.split(",")
         end