Closed wookayin closed 9 months ago
Thanks for flagging!
This looks like a bug; I would've expected the description text to wrap to the next line. It appears it does when I just make your subcommand a little bit longer:
I can look into this in the next few days.
Thanks for the fix. How about also making the constants max_help_position = 24
, etc. as a static field of the class?
Currently none of this is exposed in the public API. Are you proposing to add an argument to tyro.cli()
?
We probably don't want to soil the arguments of tyro.cli
.
I was thinking of something like:
class TyroArgparseHelpFormatter(argparse.RawDescriptionHelpFormatter):
+ indent_increment = 4
+ max_help_position = 24
def __init__(self, prog: str):
- indent_increment = 4
width = shutil.get_terminal_size().columns - 2
- max_help_position = 24
- super().__init__(prog, indent_increment, max_help_position, width)
+ super().__init__(prog, self.indent_increment, self.max_help_position, width)
so that one can do monkey-patching of those values at users' own risk (although it's not a public API yet). But given that the truncation no longer happens, I'm fine with not having this too.
EDIT: Hmm this might be confusing because the field would have no effect if changed/used after the constructor, so it might be not worth doing it unless we introduce more fine-grained customization of internal classes; nvm..
Got it, ok!
Since you don't feel strongly I'll just hold off, if we want more configuration of how the helptext is displayed I'd prefer to make more intentional decisions on that. Ideally we could revisit it jointly with things like the design of tyro.extras.set_accent_color(). But it's challenging to prioritize...
The subcommand
generate_completion
is too long, truncated at 24 characters. How can I configure this so that no truncation would happen?This value 24 is hard-coded at: https://github.com/brentyi/tyro/blob/v0.5.18/tyro/_argparse_formatter.py#L841
It would have been much better if this were a static field/member rather than a local variable. Ideally, we should have an API to configure the behavior on
help_position
or the width.The version I used: