1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-24 04:05:39 +01:00
svtplay-dl/lib
Olof Johansson 0e4fc4899c utils.parser: Allow direct access to argparse object before use
The svtplay_dl.util.parser.parser() function builds an argparse object
and applies it to sys.argv. This change splits this to two functions: a
gen_parser() that generates the argparse object and the parser()
function that still implements the old behavior (by itself calling
gen_parser()).

By being able to intercept the generated argparse object before it has
consumed the command line arguments, we can do things like generating
manpages directly from the argument definitions (kudos to the
argparse-manpage project). Such a tool can either be integrated in the
release process of svtplay-dl (affecting the set of dependencies for
everybody), or integrated as part of the distribution building process
(limiting the dependency to opt-in usage from distributions --- or
opening up for other solutions). This change will allow for either, but
does not introduce any new dependencies.

Whereas svtplay-dl supplies its version number as input to the argparse
generation, the argparse-manpage tool requires the function to be
callable without arguments; hence the "unknown" default value for the
version parameter to gen_parser(). It is overriden when used by
svtplay-dl and does not end up in the manpage when used with
argparse-manpage.

This change is backwards compatible; the interface or behavior of
parser() does not change.
2020-10-12 15:03:20 +02:00
..
svtplay_dl utils.parser: Allow direct access to argparse object before use 2020-10-12 15:03:20 +02:00
Makefile bring back old method of making the binary 2018-07-10 22:22:51 +02:00