@@ -934,7 +934,6 @@ class _ContextOptions:
934934
935935 :ivar name: Name of the script/program. Defaults to the filename or module name (depending on invocation method).
936936
937- :ivar debug: Normally false. If true, will log all calls to argparse and will log how commands are called.
938937 :ivar call_ancestors: Normally false. If true, `git init` will first call `git()`, then `git__init()`. Calls all
939938 members of the hierarchy. This allows parents to handle options. Parents can determine if they are actually the
940939 target command (instead of being called through the heirarchy) through the `is_target()` method.
@@ -959,7 +958,6 @@ class _ContextOptions:
959958 name : Optional [str ]
960959
961960 # Behavior options
962- debug : bool
963961 call_ancestors : bool
964962 always_subcommand : bool
965963 auto_alias_cmds : bool
@@ -1239,15 +1237,14 @@ def _set_up_args(self, cmd: _Command) -> None:
12391237 )
12401238 parser .set_defaults (** {arg_ .arg_name : arg_ .default })
12411239 for entry in _info_for_flags (arg_ .arg_name , arg_ .arg_value_type ):
1242- if self ._options .debug :
1243- logger .debug (
1244- f'Parser({ parser .prog .partition (" " )[2 ]!r} ).add_argument('
1245- f"*{ entry .option !r} , "
1246- f"action={ _EnumFlagAction !r} , "
1247- f"const={ entry !r} , "
1248- f"nargs={ 0 !r} , "
1249- f"help={ entry .description !r} ,)"
1250- )
1240+ logger .debug (
1241+ f'Parser({ parser .prog .partition (" " )[2 ]!r} ).add_argument('
1242+ f"*{ entry .option !r} , "
1243+ f"action={ _EnumFlagAction !r} , "
1244+ f"const={ entry !r} , "
1245+ f"nargs={ 0 !r} , "
1246+ f"help={ entry .description !r} ,)"
1247+ )
12511248 parser .add_argument (
12521249 * entry .option ,
12531250 action = _EnumFlagAction ,
@@ -1332,12 +1329,9 @@ def _set_up_args(self, cmd: _Command) -> None:
13321329 modifier .modify_arg_dict (cmd , arg_ , add_arg_kwargs )
13331330
13341331 # Add the argument to the parser
1335- if self ._options .debug :
1336- logger .debug (
1337- f'Parser({ parser .prog .partition (" " )[2 ]!r} ).add_argument('
1338- f"*{ arg_names !r} , "
1339- f"**{ add_arg_kwargs !r} )"
1340- )
1332+ logger .debug (
1333+ f'Parser({ parser .prog .partition (" " )[2 ]!r} ).add_argument(' f"*{ arg_names !r} , " f"**{ add_arg_kwargs !r} )"
1334+ )
13411335 parser .add_argument (* arg_names , ** add_arg_kwargs )
13421336
13431337 def _build_subparser_tree (self , command_decorator_info : _CommandDecoratorInfo ) -> str :
@@ -1356,14 +1350,13 @@ def _build_subparser_tree(self, command_decorator_info: _CommandDecoratorInfo) -
13561350 if ancestor not in self ._parsers :
13571351 # Dummy parser - since there's nothing to run, require the subparser.
13581352 required_subparser = True
1359- if self ._options .debug :
1360- logger .debug (
1361- f"Subparsers({ prev_ancestor !r} ).add_parser("
1362- f'{ ancestor .split (" " )[- 1 ]!r} , '
1363- f'help={ "" !r} , '
1364- f"formatter_class={ self ._formatter !r} , "
1365- f"**{ self ._extra_argparser_options !r} ,)"
1366- )
1353+ logger .debug (
1354+ f"Subparsers({ prev_ancestor !r} ).add_parser("
1355+ f'{ ancestor .split (" " )[- 1 ]!r} , '
1356+ f'help={ "" !r} , '
1357+ f"formatter_class={ self ._formatter !r} , "
1358+ f"**{ self ._extra_argparser_options !r} ,)"
1359+ )
13671360 self ._parsers [ancestor ] = self ._subparsers [prev_ancestor ].add_parser (
13681361 ancestor .split (" " )[- 1 ],
13691362 help = "" ,
@@ -1377,14 +1370,13 @@ def _build_subparser_tree(self, command_decorator_info: _CommandDecoratorInfo) -
13771370 raise ArguablyException (
13781371 f"Command `{ ancestor } ` cannot have both subcommands and positional arguments."
13791372 )
1380- if self ._options .debug :
1381- logger .debug (
1382- f"Parser({ ancestor !r} ).add_subparsers("
1383- f"parser_class={ _ArgumentParser !r} , "
1384- f"dest={ ancestor_cmd .get_subcommand_metavar (self ._options .command_metavar )!r} , "
1385- f"metavar={ self ._options .command_metavar !r} , "
1386- f"required={ required_subparser !r} ,)"
1387- )
1373+ logger .debug (
1374+ f"Parser({ ancestor !r} ).add_subparsers("
1375+ f"parser_class={ _ArgumentParser !r} , "
1376+ f"dest={ ancestor_cmd .get_subcommand_metavar (self ._options .command_metavar )!r} , "
1377+ f"metavar={ self ._options .command_metavar !r} , "
1378+ f"required={ required_subparser !r} ,)"
1379+ )
13881380 self ._subparsers [ancestor ] = self ._parsers [ancestor ].add_subparsers (
13891381 parser_class = _ArgumentParser ,
13901382 dest = ancestor_cmd .get_subcommand_metavar (self ._options .command_metavar ),
@@ -1406,7 +1398,6 @@ def error(self, message: str) -> None:
14061398 def run (
14071399 self ,
14081400 name : Optional [str ] = None ,
1409- debug : bool = False ,
14101401 call_ancestors : bool = False ,
14111402 always_subcommand : bool = False ,
14121403 auto_alias_cmds : bool = False ,
@@ -1433,14 +1424,13 @@ def run(
14331424 description = "" if __main__ .__doc__ is None else __main__ .__doc__ .partition ("\n \n \n " )[0 ]
14341425
14351426 # Set up the root parser
1436- if self ._options .debug :
1437- logger .debug (
1438- f'Initializing { "__root__" !r} parser: _ArgumentParser('
1439- f"prog={ self ._options .name !r} , "
1440- f"description={ description !r} , "
1441- f"formatter_class={ self ._formatter !r} , "
1442- f"**{ self ._extra_argparser_options !r} )"
1443- )
1427+ logger .debug (
1428+ f'Initializing { "__root__" !r} parser: _ArgumentParser('
1429+ f"prog={ self ._options .name !r} , "
1430+ f"description={ description !r} , "
1431+ f"formatter_class={ self ._formatter !r} , "
1432+ f"**{ self ._extra_argparser_options !r} )"
1433+ )
14441434 root_parser = _ArgumentParser (
14451435 prog = self ._options .name ,
14461436 description = description ,
@@ -1459,13 +1449,12 @@ def run(
14591449 else :
14601450 argparse_version_flags = ("--version" ,)
14611451 version_string = f"%(prog)s { __main__ .__version__ } "
1462- if self ._options .debug :
1463- logger .debug (
1464- f'Parser({ "__root__" !r} ).add_argument('
1465- f"*{ argparse_version_flags !r} , "
1466- f'action={ "version" !r} , '
1467- f"version={ version_string !r} )"
1468- )
1452+ logger .debug (
1453+ f'Parser({ "__root__" !r} ).add_argument('
1454+ f"*{ argparse_version_flags !r} , "
1455+ f'action={ "version" !r} , '
1456+ f"version={ version_string !r} )"
1457+ )
14691458 root_parser .add_argument (* argparse_version_flags , action = "version" , version = version_string )
14701459
14711460 # Check the number of commands we have
@@ -1503,16 +1492,15 @@ def run(
15031492
15041493 # Add the parser for the command
15051494 if not only_one_cmd and cmd .name != "__root__" :
1506- if self ._options .debug :
1507- logger .debug (
1508- f"Subparsers({ parent_name !r} ).add_parser("
1509- f'{ cmd .name .split (" " )[- 1 ]!r} , '
1510- f"aliases={ [cmd .alias ] if cmd .alias is not None else []!r} , "
1511- f"help={ cmd .description !r} , "
1512- f"description={ cmd .description !r} , "
1513- f"formatter_class={ self ._formatter !r} , "
1514- f"**{ self ._extra_argparser_options !r} )"
1515- )
1495+ logger .debug (
1496+ f"Subparsers({ parent_name !r} ).add_parser("
1497+ f'{ cmd .name .split (" " )[- 1 ]!r} , '
1498+ f"aliases={ [cmd .alias ] if cmd .alias is not None else []!r} , "
1499+ f"help={ cmd .description !r} , "
1500+ f"description={ cmd .description !r} , "
1501+ f"formatter_class={ self ._formatter !r} , "
1502+ f"**{ self ._extra_argparser_options !r} )"
1503+ )
15161504 self ._parsers [cmd .name ] = self ._subparsers [parent_name ].add_parser (
15171505 cmd .name .split (" " )[- 1 ],
15181506 aliases = [cmd .alias ] if cmd .alias is not None else [],
0 commit comments