@@ -157,55 +157,55 @@ def parse(self, argument_string):
157157 # Return new Arguments with converted options
158158 return Arguments (arguments .expressions , arguments .flags , converted_options )
159159
160- def help_text (self , command_name , terminal ):
161- """Generate help text from usage specification.
160+ def print_to (self , terminal , command_name ):
161+ """Print help text from usage specification.
162162
163163 Args:
164- command_name: Name of the command (e.g., "rb-print")
165164 terminal: Terminal for colored output
166-
167- Returns:
168- Formatted help string with usage, parameters, options, and flags
165+ command_name: Name of the command (e.g., "rb-print")
169166 """
170167 import format as fmt
171168
172169 # Summary with color
173- lines = [terminal .print (fmt .bold , self .summary , fmt .reset ), "" ]
170+ terminal .print (fmt .bold , self .summary , fmt .reset )
171+ terminal .print ()
174172
175- # Build usage line
176- usage_parts = [terminal .print (fmt .bold , command_name , fmt .reset )]
173+ # Print usage line
174+ terminal .print ("Usage: " , end = '' )
175+ terminal .print (fmt .bold , command_name , fmt .reset , end = '' )
177176
178177 for param_name , _ in self .parameters :
179- usage_parts .append (terminal .print (fmt .placeholder , f"<{ param_name } >" , fmt .reset ))
178+ terminal .print (' ' , end = '' )
179+ terminal .print (fmt .placeholder , f"<{ param_name } >" , fmt .reset , end = '' )
180180
181181 # Add option placeholders
182182 for option_name in self .options .keys ():
183- opt_placeholder = f"[-- { option_name } N]"
184- usage_parts . append ( terminal .print (fmt .placeholder , opt_placeholder , fmt .reset ) )
183+ terminal . print ( ' ' , end = '' )
184+ terminal .print (fmt .placeholder , f"[-- { option_name } N]" , fmt .reset , end = '' )
185185
186186 # Add flag placeholders
187187 for flag_name , _ in self .flags :
188- flag_placeholder = f"[-- { flag_name } ]"
189- usage_parts . append ( terminal .print (fmt .placeholder , flag_placeholder , fmt .reset ) )
188+ terminal . print ( ' ' , end = '' )
189+ terminal .print (fmt .placeholder , f"[-- { flag_name } ]" , fmt .reset , end = '' )
190190
191- lines . append ( f"Usage: { ' ' . join ( usage_parts ) } " )
192- lines . append ( "" )
191+ terminal . print ( )
192+ terminal . print ( )
193193
194194 # Parameter descriptions
195195 if self .parameters :
196- lines . append ( terminal .print (fmt .title , "Parameters:" , fmt .reset ) )
196+ terminal .print (fmt .title , "Parameters:" , fmt .reset )
197197
198198 for param_name , param_desc in self .parameters :
199- param_str = terminal .print (fmt .symbol , param_name , fmt .reset )
199+ terminal .print (" " , fmt .symbol , param_name , fmt .reset , end = '' )
200200 if param_desc :
201- lines . append (f" { param_str :<15 } { param_desc } " )
201+ terminal . print (f" - { param_desc } " )
202202 else :
203- lines . append ( f" { param_str } " )
204- lines . append ( "" )
203+ terminal . print ( )
204+ terminal . print ( )
205205
206206 # Option descriptions
207207 if self .options :
208- lines . append ( terminal .print (fmt .title , "Options:" , fmt .reset ) )
208+ terminal .print (fmt .title , "Options:" , fmt .reset )
209209
210210 for option_name , opt_spec in self .options .items ():
211211 opt_type , opt_default = opt_spec [0 ], opt_spec [1 ]
@@ -214,40 +214,34 @@ def help_text(self, command_name, terminal):
214214 type_str = opt_type .__name__ if hasattr (opt_type , '__name__' ) else str (opt_type )
215215 default_str = f" (default: { opt_default } )" if opt_default is not None else ""
216216
217- opt_str = terminal .print (fmt .symbol , f"--{ option_name } " , fmt .reset )
218- type_part = terminal .print (fmt .placeholder , f" <{ type_str } >" , fmt .reset )
217+ terminal .print (" " , fmt .symbol , f"--{ option_name } " , fmt .reset , end = '' )
218+ terminal .print (fmt .placeholder , f" <{ type_str } >" , fmt .reset , end = '' )
219+ terminal .print (default_str )
219220
220221 if opt_desc :
221- lines .append (f" { opt_str } { type_part } { default_str } " )
222- lines .append (f" { opt_desc } " )
223- else :
224- lines .append (f" { opt_str } { type_part } { default_str } " )
225- lines .append ("" )
222+ terminal .print (f" { opt_desc } " )
223+ terminal .print ()
226224
227225 # Flag descriptions
228226 if self .flags :
229- lines . append ( terminal .print (fmt .title , "Flags:" , fmt .reset ) )
227+ terminal .print (fmt .title , "Flags:" , fmt .reset )
230228
231229 for flag_name , flag_desc in self .flags :
232- flag_str = terminal .print (fmt .symbol , f"--{ flag_name } " , fmt .reset )
230+ terminal .print (" " , fmt .symbol , f"--{ flag_name } " , fmt .reset , end = '' )
233231 if flag_desc :
234- lines . append (f" { flag_str :<15 } { flag_desc } " )
232+ terminal . print (f" - { flag_desc } " )
235233 else :
236- lines . append ( f" { flag_str } " )
237- lines . append ( "" )
234+ terminal . print ( )
235+ terminal . print ( )
238236
239237 # Examples section
240238 if self .examples :
241- lines . append ( terminal .print (fmt .title , "Examples:" , fmt .reset ) )
239+ terminal .print (fmt .title , "Examples:" , fmt .reset )
242240
243241 for example_cmd , example_desc in self .examples :
244- cmd_str = terminal .print (fmt .example , f" { example_cmd } " , fmt .reset )
245- lines .append (cmd_str )
242+ terminal .print (fmt .example , f" { example_cmd } " , fmt .reset )
246243 if example_desc :
247- lines .append (f" { example_desc } " )
248- lines .append ("" )
249-
250- return '\n ' .join (lines )
244+ terminal .print (f" { example_desc } " )
251245
252246class ArgumentParser :
253247 """Parse GDB command arguments handling nested brackets, quotes, and flags.
0 commit comments