pyrocko.cli¶
Command line argument parsing infrastructure for Pyrocko’s tools.
Classes
|
Tweaks and extends the standard argument parser to simplify the generation of the online docs. |
- class PyrockoArgumentParser(prog=None, usage=None, description=None, epilog=None, **kwargs)[source]¶
Bases:
ArgumentParserTweaks and extends the standard argument parser to simplify the generation of the online docs.
We want to convert the
--helpoutputs torstfor the html docs. Problem is that argparse’sHelpFormatterto date have no public interface which we could use to achieve this. The solution here is a bit clunky but works ok for our purposes. We allow markup like``code``which is kept when producingrst(by parsing the final--helpoutput) but stripped out when doing normal--help. This leads to a problem with the internal output wrapping of argparse which it does before the stripping. To solve, we render with argparse to a very wide width and do the wrapping in post-processing.``code``is replaced with justcodein normal output.```code```is replaced with'code'in normal output and with``code``inrstoutput.rstoutput is selected with environment variablePYROCKO_RST_HELP=1. The scriptmaintenance/argparse_help_to_rst.pyextracts thersthelp and generates therstfiles for the docs.