@@ -479,7 +479,7 @@ def remove_tmp_files(self):
479
479
fu .rm_file_list (self .tmp_files , self .out_log )
480
480
481
481
@classmethod
482
- def get_main (cls , launcher , description ):
482
+ def get_main (cls , launcher , description , custom_flags = None ):
483
483
"""Get command line execution of this building block. Please check the command line documentation."""
484
484
def main ():
485
485
# Get the arguments and properties from the class docstring
@@ -491,6 +491,7 @@ def main():
491
491
"-c" , "--config" , required = False ,
492
492
help = "This file can be a YAML file, JSON file or JSON string" ,
493
493
)
494
+ required_args = parser .add_argument_group ("required arguments" )
494
495
# Use the doc_arguments_dict to add arguments to the parser
495
496
# If we have only one input or output argument, we can use shorthand flags -i/-o
496
497
input_args = [arg for arg , arg_dict in doc_arguments_dict .items () if arg_dict .get ("input_output" , "" ).lower ().startswith ("input" )]
@@ -499,15 +500,20 @@ def main():
499
500
for argument , argument_dict in doc_arguments_dict .items ():
500
501
# Determine if we should add shorthand flags
501
502
shorthand_flags = [f'--{ argument } ' ]
502
- if len (input_args ) == 1 and argument in input_args :
503
+
504
+ # Check if custom flags are provided for this argument
505
+ if custom_flags and argument in custom_flags :
506
+ shorthand_flags .insert (0 , custom_flags [argument ])
507
+ elif len (input_args ) == 1 and argument in input_args :
503
508
shorthand_flags .insert (0 , '-i' )
504
509
elif len (output_args ) == 1 and argument in output_args :
505
510
shorthand_flags .insert (0 , '-o' )
506
511
512
+ help_str = argument_dict .get ("description" , "" ) + f". Accepted formats: { ', ' .join (argument_dict .get ('formats' , {}).keys ())} ."
507
513
if argument_dict ["optional" ]:
508
- parser .add_argument (* shorthand_flags , required = False , help = argument_dict . get ( "description" , "" ) )
514
+ parser .add_argument (* shorthand_flags , required = False , help = help_str )
509
515
else :
510
- parser .add_argument (* shorthand_flags , required = True , help = argument_dict . get ( "description" , "" ) )
516
+ required_args .add_argument (* shorthand_flags , required = True , help = help_str )
511
517
# Parse the arguments from the command line
512
518
args = parser .parse_args ()
513
519
args .config = args .config or "{}"
0 commit comments