@@ -26,12 +26,14 @@ def display_help(self_module, input_params):
2626 generic_inputs = self_module .input_flags_converted_to_env
2727
2828 # Step 2: Search for scripts
29- search_result = self_module .search (input_params .copy ())
30- if search_result ['return' ] > 0 :
31- return search_result
3229
33- scripts_list = search_result ['list' ]
34- if not scripts_list :
30+ r = self_module ._select_script (input_params )
31+ if r ['return' ] > 0 :
32+ return r
33+
34+ script = r ['script' ]
35+
36+ if not script :
3537
3638 print ("" )
3739 print ("Please use script tags or alias/uid to get help for a specific script" )
@@ -41,17 +43,14 @@ def display_help(self_module, input_params):
4143 print_input_descriptions (generic_inputs )
4244
4345 else :
44- # Step 4: Iterate over scripts and generate help output
45- for script in sorted (
46- scripts_list , key = lambda x : x .meta .get ('alias' , '' )):
47- metadata = script .meta
48- script_path = script .path
49- print_script_help (
50- metadata ,
51- script_path ,
52- generic_inputs ,
53- env ,
54- self_module )
46+ metadata = script .meta
47+ script_path = script .path
48+ print_script_help (
49+ metadata ,
50+ script_path ,
51+ generic_inputs ,
52+ env ,
53+ self_module )
5554
5655 return {'return' : 0 }
5756
@@ -146,22 +145,28 @@ def print_input_descriptions(input_descriptions):
146145 if not input_descriptions :
147146 print ("\t No inputs" )
148147
149- for key in input_descriptions :
148+ for key in sorted ( input_descriptions ) :
150149 field = input_descriptions [key ]
151150 env_key = field .get ('env_key' , f"""MLC_TMP_{ key .upper ()} """ )
152151 desc = field .get ('desc' )
153- default = field .get ('default' , ' None' )
152+ default = field .get ('default' , None )
154153 choices = field .get ("choices" , "" )
155154 dtype = infer_type (field )
155+
156+ line = []
157+
156158 # Use .ljust(15) to ensure the key occupies 15 characters minimum
157- print (f"\t --{ key .ljust (26 )} : maps to --env.{ env_key } " )
158- if desc :
159- print (f"\t { ' ' .ljust (30 )} Desc: { desc } " )
160- print (f"\t { ' ' .ljust (30 )} Default: { default } " )
159+ line .append (f"--{ key .ljust (26 )} : maps to --env.{ env_key } " )
160+ if default :
161+ line .append (f"{ ' ' .ljust (30 )} Default: { default } " )
162+ # if dtype:
163+ # line.append(f"{' '.ljust(30)}Type: {dtype}")
161164 if choices :
162- print (f"\t { ' ' .ljust (30 )} Choices: { choices } " )
163- if dtype :
164- print (f"\t { ' ' .ljust (30 )} Type: { dtype } " )
165+ line .append (f"{ ' ' .ljust (30 )} Choices: { choices } " )
166+ if desc :
167+ line .append (f"{ ' ' .ljust (30 )} Desc: { desc } " )
168+
169+ print ("\t " + "\t \n \t " .join (line ))
165170 print ("" )
166171
167172
0 commit comments