Overall I have found it to be very much not worth it adding typer as a dependency. Hard pass.
> Passing arguments to functions is thread-safe, but that soon becomes tedious when there’s more than a few or when they need to pass down through several layers of calls before reaching the point they should affect. Introducing a new setting to existing code is often easier with a parameter object than adding arguments.
But also, if you really wanted to, you could set the argsparse object to a global variable and then import it everywhere else. So that is not a limitation.
sub1 = [create subparser]
sub1.add_argument('-x')
sub2 = [create subparser]
If I copy "sub1.add_argument" and put it under "sub2", and forget to change "sub1" to "sub2", it is a hard to track down bug. I've had this happen a lot as the parser gets more complex.Typer completely eliminates this potential bug, because the arguments are defined as type annotations in the sub-command function itself.
> arguments are defined as type annotations in the sub-command function itself
So you duplicate logic in your type definitions instead of as instructions. Whatever makes you happy i guess.
I have a program I'm working on right now that does user-initiated argument parsing, and argparse is a great fit for it. I'd love to have a text-based UI as an option to drop users into, but Textualize requires Click (IIRC), and using Textual directly in my code to create the UI I've spent hours on and had absolutely no luck even getting started.