In addition to the parsing library, pyproject-parser
has a command-line interface for validating
and reformatting pyproject.toml
files.
.. versionadded:: 0.2.0
.. extras-require:: cli :pyproject: :scope: CLI
.. latex:vspace:: -9px
.. latex:vspace:: -10px
.. latex:vspace:: -5px
.. latex:samepage:: .. click:: pyproject_parser.__main__:check :prog: pyproject-parser check :nested: none
.. latex:vspace:: 15px
The :option:`-P / --parser-class <-P>` and :option:`-E / --encoder-class <-E>` options
must be in the form <module_name>:<object_name>
.
or example, pyproject_parser:PyProject
, which corresponds to :class:`pyproject_parser.PyProject`.
The module_name
may be any valid Python module, including those containing .
.
.. latex:clearpage::
.. click:: pyproject_parser.__main__:reformat :prog: pyproject-parser reformat :nested: none
.. versionadded:: 0.5.0
.. click:: pyproject_parser.__main__:info :prog: pyproject-parser info :nested: none
.. latex:vspace:: 20px
# Print the readme text
echo -e $(python3 -m pyproject_parser info project.readme.text -r | tr -d '"')
# Print the license filename
python3 -m pyproject_parser info project.license.file
# Get one of the project's URLs
python3 -m pyproject_parser info project.urls."Source Code"
# Install the build-system requirements with pip
pip install $(python3 -m pyproject_parser info build-system.requires | jq -r 'join(" ")')
# Dump one of the tool sub-tables
python3 -m pyproject_parser info tool.dependency-dash
pyproject-parser
can also be used as a pre-commit hook.
To do so, add the following to your
.pre-commit-config.yaml file:
.. pre-commit:: :rev: 0.10.0 :hooks: check-pyproject,reformat-pyproject