@@ -45,7 +45,6 @@ class CommandLineArgUtil(object):
45
45
MODEL_FILE_SWITCH = '-model_file'
46
46
OPSS_WALLET_SWITCH = '-opss_wallet'
47
47
OPSS_WALLET_PASSPHRASE = '-opss_wallet_passphrase'
48
- PATH_SWITCH = '-path'
49
48
PREVIOUS_MODEL_FILE_SWITCH = '-prev_model_file'
50
49
VARIABLE_FILE_SWITCH = '-variable_file'
51
50
RCU_DB_SWITCH = '-rcu_db'
@@ -64,6 +63,8 @@ class CommandLineArgUtil(object):
64
63
RUN_RCU_SWITCH = '-run_rcu'
65
64
TARGET_VERSION_SWITCH = '-target_version'
66
65
TARGET_MODE_SWITCH = '-target_mode'
66
+ # phony arg used as a key to store the trailing (non-switched) arguments
67
+ TRAILING_ARGS_SWITCH = '-trailing_arguments'
67
68
ATTRIBUTES_ONLY_SWITCH = '-attributes_only'
68
69
FOLDERS_ONLY_SWITCH = '-folders_only'
69
70
RECURSIVE_SWITCH = '-recursive'
@@ -131,12 +132,13 @@ def set_allow_multiple_models(self, allow_multiple_models):
131
132
"""
132
133
self ._allow_multiple_models = allow_multiple_models
133
134
134
- def process_args (self , args , tool_type = TOOL_TYPE_DEFAULT ):
135
+ def process_args (self , args , tool_type = TOOL_TYPE_DEFAULT , trailing_arg_count = 0 ):
135
136
"""
136
137
This method parses the command-line arguments and returns dictionaries of the required and optional args.
137
138
138
139
:param args: sys.argv
139
140
:param tool_type: optional, type of tool for special argument processing
141
+ :param trailing_arg_count: optional, the number of trailing (no switch) arguments
140
142
:return: the required and optional argument dictionaries
141
143
:raises CLAException: if argument processing encounters a usage or validation exception
142
144
"""
@@ -156,6 +158,9 @@ def process_args(self, args, tool_type=TOOL_TYPE_DEFAULT):
156
158
ex .setExitCode (self .HELP_EXIT_CODE )
157
159
raise ex
158
160
161
+ args = self ._check_trailing_arguments (args , trailing_arg_count )
162
+ args_len = len (args )
163
+
159
164
idx = 1
160
165
while idx < args_len :
161
166
key = args [idx ]
@@ -280,9 +285,6 @@ def process_args(self, args, tool_type=TOOL_TYPE_DEFAULT):
280
285
value , idx = self ._get_arg_value (args , idx , key )
281
286
full_path = self ._validate_domain_resource_file_arg (value )
282
287
self ._add_arg (key , full_path , True )
283
- elif self .is_path_key (key ):
284
- value , idx = self ._get_arg_value (args , idx , key )
285
- self ._add_arg (key , value )
286
288
elif self .is_boolean_switch (key ):
287
289
self ._add_arg (key , True )
288
290
else :
@@ -314,6 +316,38 @@ def _get_arg_value(self, args, index, key):
314
316
raise ex
315
317
return args [index ], index
316
318
319
+ def _check_trailing_arguments (self , args , trailing_arg_count ):
320
+ """
321
+ Remove any trailing (no switch) arguments from the argument list and add them to the required result.
322
+ example:
323
+ command.sh -oracle_home /oracle file1 file2
324
+ file1 and file2 are trailing arguments
325
+
326
+ :param args: the arguments to be examined
327
+ :param trailing_arg_count: the number of trailing arguments that are expected
328
+ :return: the argument list, with the trailing arguments removed
329
+ :raises CLAException: if there are not enough arguments present
330
+ """
331
+ method_name = '_check_trailing_arguments'
332
+ args_len = len (args )
333
+
334
+ # verify there are enough arguments for any trailing (no switch) args
335
+ if args_len < trailing_arg_count + 1 :
336
+ ex = exception_helper .create_cla_exception ('WLSDPLY-01639' , trailing_arg_count )
337
+ ex .setExitCode (self .ARG_VALIDATION_ERROR_EXIT_CODE )
338
+ self ._logger .throwing (ex , class_name = self ._class_name , method_name = method_name )
339
+ raise ex
340
+
341
+ # set required_result['TRAILING_ARGS'] to list of trailing args (such as ['file1', 'file2'])
342
+ trailing_args = []
343
+ for index in range (args_len - trailing_arg_count , args_len ):
344
+ arg = args [index ]
345
+ trailing_args .append (arg )
346
+ self ._required_result [self .TRAILING_ARGS_SWITCH ] = trailing_args
347
+
348
+ # remove trailing args from the list and return revised list
349
+ return args [0 :(args_len - trailing_arg_count )]
350
+
317
351
def get_help_key (self ):
318
352
return self .HELP_SWITCH
319
353
@@ -930,9 +964,6 @@ def _validate_domain_resource_file_arg(self, value):
930
964
raise ex
931
965
return variables .getAbsolutePath ()
932
966
933
- def is_path_key (self , key ):
934
- return self .PATH_SWITCH == key
935
-
936
967
def is_boolean_switch (self , key ):
937
968
return key in self .BOOLEAN_SWITCHES
938
969
0 commit comments