@@ -300,17 +300,21 @@ def tapify(
300
300
known_only : bool = False ,
301
301
command_line_args : Optional [List [str ]] = None ,
302
302
explicit_bool : bool = False ,
303
+ description : Optional [str ] = None ,
303
304
** func_kwargs ,
304
305
) -> OutputType :
305
306
"""Tapify initializes a class or runs a function by parsing arguments from the command line.
306
307
307
308
:param class_or_function: The class or function to run with the provided arguments.
308
309
:param known_only: If true, ignores extra arguments and only parses known arguments.
309
- :param command_line_args: A list of command line style arguments to parse (e.g., ['--arg', 'value']). If None,
310
+ :param command_line_args: A list of command line style arguments to parse (e.g., ` ['--arg', 'value']` ). If None,
310
311
arguments are parsed from the command line (default behavior).
311
- :param explicit_bool: Booleans can be specified on the command line as " --arg True" or " --arg False" rather than
312
- " --arg" . Additionally, booleans can be specified by prefixes of True and False with any
312
+ :param explicit_bool: Booleans can be specified on the command line as ` --arg True` or ` --arg False` rather than
313
+ ` --arg` . Additionally, booleans can be specified by prefixes of True and False with any
313
314
capitalization as well as 1 or 0.
315
+ :param description: The description displayed in the help message—the same description passed in
316
+ `argparse.ArgumentParser(description=...)`. By default, it's extracted from `class_or_function`'s
317
+ docstring.
314
318
:param func_kwargs: Additional keyword arguments for the function. These act as default values when parsing the
315
319
command line arguments and overwrite the function defaults but are overwritten by the parsed
316
320
command line arguments.
@@ -320,8 +324,9 @@ def tapify(
320
324
param_to_description = {param .arg_name : param .description for param in docstring .params }
321
325
tap_data = _tap_data (class_or_function , param_to_description , func_kwargs )
322
326
tap_class = _tap_class (tap_data .args_data )
323
- # Create a Tap object with a description from the docstring of the class or function
324
- description = "\n " .join (filter (None , (docstring .short_description , docstring .long_description )))
327
+ # Create a Tap object
328
+ if description is None :
329
+ description = "\n " .join (filter (None , (docstring .short_description , docstring .long_description )))
325
330
tap = tap_class (description = description , explicit_bool = explicit_bool )
326
331
327
332
# If any func_kwargs remain, they are not used in the function, so raise an error
0 commit comments