from rich_argparse import ArgumentDefaultsRichHelpFormatter
parser = argparse.ArgumentParser(formatter_class=ArgumentDefaultsRichHelpFormatter)
argh.add_commands(parser, [foo, bar, baz])
Running the above code means that my-app --help prints colorfully-formatted help text - but running my-app foo --help does not. Inspecting the parser._actions[1].choices shows me that the parsers that have been added by argh are using the CustomFormatter defined within Argh rather than ArgumentDefaultsRichHelpFormatter.
My instinct as a user is that if I've defined a formatter_class on the top level parser object, I'd like for argh, as it performs its magic, to reuse that formatter class on all calls to add_parser.
I think this is probably where the 'bug' comes in, and it seems like a very easy fix; just call subparsers_action.add_parser(cmd_name, **{**{'formatter_class': parser.formatter_class}, **func_parser_kwargs}).
I don't know the codebase very well yet, so I may be missing something, but I'd love to see a change to support this 'naturally' (right now i have to go set this after the fact by iterating through the parser's private object attributes).
Running the above code means that
my-app --helpprints colorfully-formatted help text - but runningmy-app foo --helpdoes not. Inspecting theparser._actions[1].choicesshows me that the parsers that have been added byarghare using theCustomFormatterdefined within Argh rather thanArgumentDefaultsRichHelpFormatter.My instinct as a user is that if I've defined a
formatter_classon the top level parser object, I'd like forargh, as it performs its magic, to reuse that formatter class on all calls toadd_parser.I think this is probably where the 'bug' comes in, and it seems like a very easy fix; just call
subparsers_action.add_parser(cmd_name, **{**{'formatter_class': parser.formatter_class}, **func_parser_kwargs}).I don't know the codebase very well yet, so I may be missing something, but I'd love to see a change to support this 'naturally' (right now i have to go set this after the fact by iterating through the parser's private object attributes).