cli.argparser: replace `"store_{true,false}"` and custom `boolean` actions with `argparse.BooleanOptionalAction`
Checklist
- This is a feature request and not a different kind of issue
- I have read the contribution guidelines
- I have checked the list of open and recently closed feature requests
Collaboration
- My request is genuine and in the best interest of the project
- I will provide feedback should a pull request be opened with a new feature implementation
Description
The stdlib's argparse module has added the BooleanOptionalAction in Python 3.9 which automatically adds --no-* CLI arguments for boolean arguments. Previously, this could only be achieved by adding duplicate negated args with the same dest, so this was never done.
Streamlink has lots of boolean CLI arguments which can't be unset once set, which is annoying, especially when they are set in the config file(s). For example the various stream transport arguments like --player-http and related ones. Replacing the action="store_true" / action="store_false" arguments with BooleanOptionalAction fixes that.
We also already have a couple of explicit --no-* arguments like --no-plugin-sideloading or --no-plugin-cache which would need to be modified accordingly.
And then there's our custom boolean action which accepts {yes,true,1,on,no,false,0,off} values. Some boolean args use this action, but lots of others don't. It's a wild and inconsistent mix that should be fixed eventually.
Considering that the custom boolean arg accepts an argument value while BooleanOptionalAction or store_{true,false} do not (separate args), this will result in a breaking change if we change those arguments.
It's not important to fix the inconsistent CLI args now, but this should be kept in mind, so I'm opening this issue as a reminder now.
There are also a couple of args which could use some shorthand argument names, like -H for --http-header for example.
Source: streamlink/streamlink