@@ -71,6 +71,7 @@ def __init__(
7171 working_dir : Optional [Union [Path , str ]] = None ,
7272 no_input_detection : bool = False ,
7373 no_output_detection : bool = False ,
74+ no_parameter_detection : bool = False ,
7475 success_codes : Optional [List [int ]] = None ,
7576 stdin : Optional [str ] = None ,
7677 stdout : Optional [str ] = None ,
@@ -80,6 +81,7 @@ def __init__(
8081
8182 self .no_input_detection = no_input_detection
8283 self .no_output_detection = no_output_detection
84+ self .no_parameter_detection = no_parameter_detection
8385
8486 if not command_line :
8587 raise errors .UsageError ("Command line can not be empty. Please specify a command to execute." )
@@ -392,23 +394,34 @@ def add_command_input(
392394
393395 mapped_stream = self .get_stream_mapping_for_value (default_value )
394396
395- self .inputs .append (
396- CommandInput (
397- id = CommandInput .generate_id (
398- plan_id = self .plan_id ,
399- position = position ,
400- postfix = mapped_stream .stream_type if mapped_stream else postfix ,
401- ),
402- default_value = default_value ,
403- prefix = prefix ,
397+ inp_param = CommandInput (
398+ id = CommandInput .generate_id (
399+ plan_id = self .plan_id ,
404400 position = position ,
405- mapped_to = mapped_stream ,
406- encoding_format = encoding_format ,
407- postfix = postfix ,
408- name = name ,
409- )
401+ postfix = mapped_stream .stream_type if mapped_stream else postfix ,
402+ ),
403+ default_value = default_value ,
404+ prefix = prefix ,
405+ position = position ,
406+ mapped_to = mapped_stream ,
407+ encoding_format = encoding_format ,
408+ postfix = postfix ,
409+ name = name ,
410410 )
411411
412+ existing_parameter = next ((p for p in self .inputs if p .name == inp_param .name ), None )
413+
414+ if existing_parameter is not None and existing_parameter .default_value == inp_param .default_value :
415+ existing_parameter .update_from (inp_param )
416+ elif existing_parameter is not None :
417+ # duplicate with different values!
418+ raise errors .ParameterError (
419+ f"Duplicate input '{ inp_param .name } ' found with differing values ('{ inp_param .default_value } '"
420+ f" vs. '{ existing_parameter .default_value } ')"
421+ )
422+ else :
423+ self .inputs .append (inp_param )
424+
412425 def add_command_output (
413426 self ,
414427 default_value : Any ,
@@ -447,20 +460,31 @@ def add_command_output(
447460 postfix = mapped_stream .stream_type if mapped_stream else postfix ,
448461 )
449462
450- self .outputs .append (
451- CommandOutput (
452- id = id ,
453- default_value = default_value ,
454- prefix = prefix ,
455- position = position ,
456- mapped_to = mapped_stream ,
457- encoding_format = encoding_format ,
458- postfix = postfix ,
459- create_folder = create_folder ,
460- name = name ,
461- )
463+ out_param = CommandOutput (
464+ id = id ,
465+ default_value = default_value ,
466+ prefix = prefix ,
467+ position = position ,
468+ mapped_to = mapped_stream ,
469+ encoding_format = encoding_format ,
470+ postfix = postfix ,
471+ create_folder = create_folder ,
472+ name = name ,
462473 )
463474
475+ existing_parameter = next ((p for p in self .outputs if p .name == out_param .name ), None )
476+
477+ if existing_parameter is not None and existing_parameter .default_value == out_param .default_value :
478+ existing_parameter .update_from (out_param )
479+ elif existing_parameter is not None :
480+ # duplicate with different values!
481+ raise errors .ParameterError (
482+ f"Duplicate output '{ out_param .name } ' found with differing values ('{ out_param .default_value } '"
483+ f" vs. '{ existing_parameter .default_value } ')"
484+ )
485+ else :
486+ self .outputs .append (out_param )
487+
464488 def add_command_output_from_input (self , input : CommandInput , name ):
465489 """Create a CommandOutput from an input."""
466490 self .inputs .remove (input )
@@ -496,16 +520,30 @@ def add_command_parameter(
496520 name : Optional [str ] = None ,
497521 ):
498522 """Create a CommandParameter."""
499- self .parameters .append (
500- CommandParameter (
501- id = CommandParameter .generate_id (plan_id = self .plan_id , position = position ),
502- default_value = default_value ,
503- prefix = prefix ,
504- position = position ,
505- name = name ,
506- )
523+ if self .no_parameter_detection and all (default_value != v for v , _ in self .explicit_parameters ):
524+ return
525+
526+ parameter = CommandParameter (
527+ id = CommandParameter .generate_id (plan_id = self .plan_id , position = position ),
528+ default_value = default_value ,
529+ prefix = prefix ,
530+ position = position ,
531+ name = name ,
507532 )
508533
534+ existing_parameter = next ((p for p in self .parameters if p .name == parameter .name ), None )
535+
536+ if existing_parameter is not None and existing_parameter .default_value == parameter .default_value :
537+ existing_parameter .update_from (parameter )
538+ elif existing_parameter is not None :
539+ # duplicate with different values!
540+ raise errors .ParameterError (
541+ f"Duplicate parameter '{ parameter .name } ' found with differing values ('{ parameter .default_value } '"
542+ f" vs. '{ existing_parameter .default_value } ')"
543+ )
544+ else :
545+ self .parameters .append (parameter )
546+
509547 def add_explicit_inputs (self ):
510548 """Add explicit inputs ."""
511549 input_paths = [input .default_value for input in self .inputs ]
0 commit comments