File: cli.rst

package info (click to toggle)
python-pyproject-parser 0.13.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,432 kB
  • sloc: python: 3,086; makefile: 5
file content (91 lines) | stat: -rw-r--r-- 2,034 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
=======
CLI
=======

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

Commands
---------

.. latex:vspace:: -10px

check
*********

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

reformat
*********

.. click:: pyproject_parser.__main__:reformat
	:prog: pyproject-parser reformat
	:nested: none


info
*********

.. versionadded:: 0.5.0

.. click:: pyproject_parser.__main__:info
	:prog: pyproject-parser info
	:nested: none

.. latex:vspace:: 20px

:bold-title:`Example Usage:`

.. code-block:: bash

	# 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


As a ``pre-commit`` hook
----------------------------

``pyproject-parser`` can also be used as a `pre-commit <https://pre-commit.com/>`_ hook.
To do so, add the following to your
`.pre-commit-config.yaml <https://pre-commit.com/#2-add-a-pre-commit-configuration>`_ file:

.. pre-commit::
	:rev: 0.13.0
	:hooks: check-pyproject,reformat-pyproject