News for hackers. Stuff that matters.
Re:Gooey: Turn almost any Python command line program into a... by linsomniac on Monday December 11, 2023 @10:27AM (#38601437)
My issue with argparse isn't that it's not global, it's that you have to create sub-parsers for multiple commands, and then add arguments to those subparsers. Those parsers are all typically defined in a central location, but copying arguments between those parsers as I define new commands can get them jumbled up because the sub-parser comes along with the argument:

    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.

Re:Gooey: Turn almost any Python command line program into a... by voidnap on Monday December 11, 2023 @11:09AM (#38601807)
Gee if only there was a way to reuse logic within a program.

> 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.