declinate 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. declinate-0.0.1/.gitignore +19 -0
  2. declinate-0.0.1/.gitlab/issue_templates/bug.md +23 -0
  3. declinate-0.0.1/.gitlab-ci.yml +50 -0
  4. declinate-0.0.1/CHANGES.rst +9 -0
  5. declinate-0.0.1/CONTRIBUTING.rst +78 -0
  6. declinate-0.0.1/LICENSE.txt +202 -0
  7. declinate-0.0.1/PKG-INFO +154 -0
  8. declinate-0.0.1/README.rst +118 -0
  9. declinate-0.0.1/docs/changes.rst +1 -0
  10. declinate-0.0.1/docs/conf.py +30 -0
  11. declinate-0.0.1/docs/index.rst +26 -0
  12. declinate-0.0.1/pyproject.toml +142 -0
  13. declinate-0.0.1/requirements-dev.txt +421 -0
  14. declinate-0.0.1/requirements.txt +10 -0
  15. declinate-0.0.1/setup.cfg +4 -0
  16. declinate-0.0.1/src/declinate/__init__.py +3 -0
  17. declinate-0.0.1/src/declinate/check.py +30 -0
  18. declinate-0.0.1/src/declinate/cli.py +394 -0
  19. declinate-0.0.1/src/declinate/declinate.py +109 -0
  20. declinate-0.0.1/src/declinate/gen.py +951 -0
  21. declinate-0.0.1/src/declinate/py.typed +0 -0
  22. declinate-0.0.1/src/declinate.egg-info/PKG-INFO +154 -0
  23. declinate-0.0.1/src/declinate.egg-info/SOURCES.txt +47 -0
  24. declinate-0.0.1/src/declinate.egg-info/dependency_links.txt +1 -0
  25. declinate-0.0.1/src/declinate.egg-info/entry_points.txt +2 -0
  26. declinate-0.0.1/src/declinate.egg-info/requires.txt +11 -0
  27. declinate-0.0.1/src/declinate.egg-info/top_level.txt +1 -0
  28. declinate-0.0.1/tests/__init__.py +3 -0
  29. declinate-0.0.1/tests/declinate/__init__.py +3 -0
  30. declinate-0.0.1/tests/declinate/cli0_minimal/__init__.py +1 -0
  31. declinate-0.0.1/tests/declinate/cli0_minimal/cli.py +321 -0
  32. declinate-0.0.1/tests/declinate/cli0_minimal/declinate.py +9 -0
  33. declinate-0.0.1/tests/declinate/cli1_arguments/__init__.py +1 -0
  34. declinate-0.0.1/tests/declinate/cli1_arguments/cli.py +386 -0
  35. declinate-0.0.1/tests/declinate/cli1_arguments/declinate.py +69 -0
  36. declinate-0.0.1/tests/declinate/cli2_groups/__init__.py +1 -0
  37. declinate-0.0.1/tests/declinate/cli2_groups/cli.py +394 -0
  38. declinate-0.0.1/tests/declinate/cli2_groups/declinate.py +84 -0
  39. declinate-0.0.1/tests/declinate/cli3_withsubcommands/__init__.py +1 -0
  40. declinate-0.0.1/tests/declinate/cli3_withsubcommands/cli.py +353 -0
  41. declinate-0.0.1/tests/declinate/cli3_withsubcommands/declinate.py +35 -0
  42. declinate-0.0.1/tests/declinate/cli4_justsubcommands/__init__.py +1 -0
  43. declinate-0.0.1/tests/declinate/cli4_justsubcommands/cli.py +349 -0
  44. declinate-0.0.1/tests/declinate/cli4_justsubcommands/declinate.py +38 -0
  45. declinate-0.0.1/tests/declinate/cli5_addargfn/__init__.py +1 -0
  46. declinate-0.0.1/tests/declinate/cli5_addargfn/cli.py +357 -0
  47. declinate-0.0.1/tests/declinate/cli5_addargfn/declinate.py +50 -0
  48. declinate-0.0.1/tests/declinate/test_cli.py +18 -0
  49. declinate-0.0.1/tests/declinate/test_consumers.py +23 -0
@@ -0,0 +1,19 @@
1
+ *.py[co]
2
+ *.egg-info/
3
+ .eggs/
4
+ __pycache__/
5
+
6
+ /build/
7
+ /dist/
8
+ /public/
9
+ /venv/
10
+
11
+ /.mypy_cache/
12
+ /.pytest_cache/
13
+ /htmlcov/
14
+ /.coverage
15
+ /coverage.xml
16
+ /report.xml
17
+
18
+ *.sw[op]
19
+ /.vscode
@@ -0,0 +1,23 @@
1
+ ## Your Environment
2
+
3
+ Thank you for taking the time to report an issue.
4
+
5
+ To more efficiently resolve this issue, we'd like to know some basic information about your system and setup.
6
+
7
+ 1) Your operating system:
8
+
9
+ 2) Version of python you are running (`python --version`):
10
+
11
+ 3) How did you install declinate? Did you use pip to install from PyPI or a repository checkout or something else?
12
+
13
+ 4) Version of declinate you have installed (`pip show declinate | grep Version`):
14
+
15
+
16
+ ## The Issue
17
+
18
+ Please describe the issue that you are experiencing.
19
+
20
+
21
+ ## Steps to Reproduce
22
+
23
+ If the issue is predictable and consistently reproducible, please list the steps here.
@@ -0,0 +1,50 @@
1
+ stages:
2
+ - test
3
+ - build
4
+
5
+
6
+ test:
7
+ stage: test
8
+ image: python:3.10
9
+ script:
10
+ - python3.10 -m venv venv
11
+ - venv/bin/python -m pip install -r requirements-dev.txt
12
+ - venv/bin/python -m pip install -e .[dev]
13
+ - venv/bin/pytest --cov-report=term --cov-report=xml --junit-xml=report.xml
14
+ - venv/bin/mypy --no-error-summary src tests
15
+ - venv/bin/ruff check src tests
16
+ - venv/bin/yapf -dpr src tests
17
+ - venv/bin/sphinx-build docs public
18
+ coverage: '/\d+\%\s*$/'
19
+ artifacts:
20
+ paths:
21
+ - public
22
+ reports:
23
+ coverage_report:
24
+ coverage_format: cobertura
25
+ path: coverage.xml
26
+ junit: report.xml
27
+
28
+
29
+ build:
30
+ stage: build
31
+ image: python:3.10
32
+ script:
33
+ - python3.10 -m venv venv
34
+ - venv/bin/python -m pip install build
35
+ - venv/bin/python -m build .
36
+ artifacts:
37
+ paths:
38
+ - dist
39
+
40
+
41
+ pages:
42
+ stage: build
43
+ image: python:3.10
44
+ script:
45
+ - ls public
46
+ artifacts:
47
+ paths:
48
+ - public
49
+ only:
50
+ - master
@@ -0,0 +1,9 @@
1
+ .. _changes:
2
+
3
+ Changes
4
+ =======
5
+
6
+ 0.0.1 - 2023-11-08
7
+ ------------------
8
+
9
+ - Initial Release
@@ -0,0 +1,78 @@
1
+ ==================
2
+ Contribution guide
3
+ ==================
4
+
5
+ Thank you for considering to contribute to declinate. Below is information on how to report issues and submit your contributions to declinate.
6
+
7
+
8
+ Rights to and license of contributions
9
+ ======================================
10
+
11
+ Declinate is licensed under `Apache 2.0`_. Your submission of an issue, merge request, comment, or code to us is:
12
+
13
+ 1. If your employer has rights in your contributions, your representation that your employer has authorized you to enter into this agreement on its behalf;
14
+
15
+ 2. Your agreement, or your employer's agreement, with the terms and conditions in this document;
16
+
17
+ 3. Your signature of the `Developer Certificate of Origin`_; and
18
+
19
+ 4. Your grant of a license to your contributions under `Apache 2.0`_.
20
+
21
+
22
+ Contributing code / merge requests
23
+ ==================================
24
+
25
+ In order to contribute code there are a few noteworthy things:
26
+
27
+ 1. Especially for non-trivial contributions, please **submit an issue first** to discuss your ideas.
28
+
29
+ 2. If your merge requests relates to an existing issue, please reference it from your merge request.
30
+
31
+ 3. When creating a merge request, please `allow collaboration`_. This enables us to make small adjustments and rebase the branch as needed. Please use dedicated branches for your merge request and don't give us access to a branch that is dear to you.
32
+
33
+ 4. Stick to *The seven rules of a great Git commit message* (see below).
34
+
35
+ 5. We require you to **sign-off your commits** (see below). Your sign-off indicates that you agreed to the terms and conditions laid out in this document, if applicable on behalf of your employer.
36
+
37
+ .. _allow collaboration:
38
+ https://docs.gitlab.com/ee/user/project/merge_requests/allow_collaboration.html
39
+
40
+
41
+ The seven rules of a great Git commit message
42
+ ---------------------------------------------
43
+
44
+ We like `The seven rules of a great Git commit message`_, summarized here for completeness, follow links for further reading.
45
+
46
+ 1. `Separate subject from body with a blank line <https://chris.beams.io/posts/git-commit/#separate>`_
47
+
48
+ 2. `Limit the subject line to 50 characters <https://chris.beams.io/posts/git-commit/#limit-50>`_ (soft-limit 50, hard-limit 72)
49
+
50
+ 3. `Start subject line with uppercase letter <https://chris.beams.io/posts/git-commit/#capitalize>`_
51
+
52
+ 4. `Do not end the subject line with a period <https://chris.beams.io/posts/git-commit/#end>`_
53
+
54
+ 5. `Use the imperative mood in the subject line <https://chris.beams.io/posts/git-commit/#imperative>`_
55
+
56
+ 6. `Wrap the body at 72 characters <https://chris.beams.io/posts/git-commit/#wrap-72>`_
57
+
58
+ 7. `Use the body to explain what and why vs. how <https://chris.beams.io/posts/git-commit/#why-not-how>`_
59
+
60
+ .. _The seven rules of a great Git commit message: https://chris.beams.io/posts/git-commit/#seven-rules
61
+
62
+
63
+ Signing off a commit
64
+ --------------------
65
+
66
+ You sign off a commit by adding a line like the following to the bottom of its commit message, separated by an empty line.
67
+
68
+ ::
69
+
70
+ Signed-off-by: Fullname <email@example.net>
71
+
72
+ Make sure it reflects your real name and email address. Git does this automatically when using ``git commit -s``.
73
+
74
+ Except for the licenses granted herein, you reserve all right, title, and interest in and to your contributions.
75
+
76
+
77
+ .. _Apache 2.0: ./LICENSE.txt
78
+ .. _Developer Certificate of Origin: https://developercertificate.org/
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.1
2
+ Name: declinate
3
+ Version: 0.0.1
4
+ Summary: CLI generator.
5
+ Author-email: Ternaris <team@ternaris.com>
6
+ License: Apache 2.0
7
+ Project-URL: Homepage, https://gitlab.com/ternaris/declinate
8
+ Project-URL: Documentation, https://ternaris.gitlab.io/declinate
9
+ Project-URL: Source, https://gitlab.com/ternaris/declinate
10
+ Project-URL: Issues, https://gitlab.com/ternaris/declinate/issues
11
+ Project-URL: Changelog, https://gitlab.com/ternaris/declinate/-/blob/master/CHANGES.rst
12
+ Keywords: cli
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/x-rst
25
+ License-File: LICENSE.txt
26
+ Requires-Dist: isort
27
+ Provides-Extra: dev
28
+ Requires-Dist: mypy; extra == "dev"
29
+ Requires-Dist: pytest; extra == "dev"
30
+ Requires-Dist: pytest-cov; extra == "dev"
31
+ Requires-Dist: ruff; extra == "dev"
32
+ Requires-Dist: sphinx; extra == "dev"
33
+ Requires-Dist: sphinx-autodoc-typehints; extra == "dev"
34
+ Requires-Dist: sphinx-rtd-theme; extra == "dev"
35
+ Requires-Dist: yapf; extra == "dev"
36
+
37
+ .. image:: https://gitlab.com/ternaris/declinate/badges/master/pipeline.svg
38
+ :target: https://gitlab.com/ternaris/declinate/-/commits/master
39
+ :alt: pipeline status
40
+
41
+ .. image:: https://gitlab.com/ternaris/declinate/badges/master/coverage.svg
42
+ :target: https://gitlab.com/ternaris/declinate/-/commits/master
43
+ :alt: coverage report
44
+
45
+ .. image:: https://img.shields.io/pypi/pyversions/declinate
46
+ :alt: python versions
47
+
48
+ =========
49
+ Declinate
50
+ =========
51
+
52
+ Declinate is a command line interface generator. It is a development tool that parses function type annotations and docstrings to generate Python CLIs:
53
+
54
+ - It uses **builtin language features** to describe CLIs.
55
+ - Declinate is **not a runtime dependency**, it compiles to vanilla Python argparse calls during development.
56
+ - Generated CLIs use lazy imports, resulting in **extremely fast startup time**.
57
+ - **Command completion** for Bash and Zsh are added by default.
58
+
59
+
60
+ Getting started
61
+ ===============
62
+
63
+ Declinate is published on PyPI and does not have any special dependencies. Simply install with pip::
64
+
65
+ pip install declinate
66
+
67
+
68
+ The package installs the ``declinate`` command to generate a CLI for a python package::
69
+
70
+ # Print python code to stdout.
71
+ declinate generate example_pkg
72
+
73
+ # Write cli.py module in example_pkg package.
74
+ declinate generate -w example_pkg
75
+
76
+
77
+ Of course, declinate's own CLI is "self-hosting" and can recreate itself::
78
+
79
+ declinate generate declinate
80
+
81
+
82
+ Declinate expects the python package to declare its command and subcommands in a module named ``declinate.py``. Here is how declinate's own "check" subcommand is declared:
83
+
84
+ .. code-block:: python
85
+
86
+ def check(package: str) -> int:
87
+ """Check if generated cli is up to date.
88
+
89
+ Args:
90
+ package: Name of the Python package.
91
+
92
+ Returns:
93
+ 0 if success.
94
+
95
+ """
96
+ if res := check_package(package):
97
+ print(res)
98
+ return 1
99
+ return 0
100
+
101
+
102
+ Take a closer look at the different example CLIs in the tests package that demonstrate the various features.
103
+
104
+
105
+ Documentation
106
+ =============
107
+
108
+ Read the `documentation <https://ternaris.gitlab.io/declinate/>`_ for further information.
109
+
110
+ .. end documentation
111
+
112
+
113
+ Contributing
114
+ ============
115
+
116
+ Thank you for considering to contribute to declinate.
117
+
118
+ To submit issues or create merge requests please follow the instructions provided in the `contribution guide <https://gitlab.com/ternaris/declinate/-/blob/master/CONTRIBUTING.rst>`_.
119
+
120
+ By contributing to declinate you accept and agree to the terms and conditions laid out in there.
121
+
122
+
123
+ Development
124
+ ===========
125
+
126
+ Clone the repository and setup your local checkout::
127
+
128
+ git clone https://gitlab.com/ternaris/declinate.git
129
+
130
+ cd declinate
131
+ python -m venv venv
132
+ . venv/bin/activate
133
+
134
+ pip install -r requirements-dev.txt
135
+ pip install -e .
136
+
137
+
138
+ This creates a new virtual environment with the necessary python dependencies and installs declinate in editable mode. The declinate code base uses pytest as its test runner, run the test suite by simply invoking::
139
+
140
+ pytest
141
+
142
+
143
+ To build the documentation from its source run sphinx-build::
144
+
145
+ sphinx-build -a docs public
146
+
147
+
148
+ The entry point to the local documentation build should be available under ``public/index.html``.
149
+
150
+
151
+ Support
152
+ =======
153
+
154
+ Professional support is available from `Ternaris <https://ternaris.com>`_.
@@ -0,0 +1,118 @@
1
+ .. image:: https://gitlab.com/ternaris/declinate/badges/master/pipeline.svg
2
+ :target: https://gitlab.com/ternaris/declinate/-/commits/master
3
+ :alt: pipeline status
4
+
5
+ .. image:: https://gitlab.com/ternaris/declinate/badges/master/coverage.svg
6
+ :target: https://gitlab.com/ternaris/declinate/-/commits/master
7
+ :alt: coverage report
8
+
9
+ .. image:: https://img.shields.io/pypi/pyversions/declinate
10
+ :alt: python versions
11
+
12
+ =========
13
+ Declinate
14
+ =========
15
+
16
+ Declinate is a command line interface generator. It is a development tool that parses function type annotations and docstrings to generate Python CLIs:
17
+
18
+ - It uses **builtin language features** to describe CLIs.
19
+ - Declinate is **not a runtime dependency**, it compiles to vanilla Python argparse calls during development.
20
+ - Generated CLIs use lazy imports, resulting in **extremely fast startup time**.
21
+ - **Command completion** for Bash and Zsh are added by default.
22
+
23
+
24
+ Getting started
25
+ ===============
26
+
27
+ Declinate is published on PyPI and does not have any special dependencies. Simply install with pip::
28
+
29
+ pip install declinate
30
+
31
+
32
+ The package installs the ``declinate`` command to generate a CLI for a python package::
33
+
34
+ # Print python code to stdout.
35
+ declinate generate example_pkg
36
+
37
+ # Write cli.py module in example_pkg package.
38
+ declinate generate -w example_pkg
39
+
40
+
41
+ Of course, declinate's own CLI is "self-hosting" and can recreate itself::
42
+
43
+ declinate generate declinate
44
+
45
+
46
+ Declinate expects the python package to declare its command and subcommands in a module named ``declinate.py``. Here is how declinate's own "check" subcommand is declared:
47
+
48
+ .. code-block:: python
49
+
50
+ def check(package: str) -> int:
51
+ """Check if generated cli is up to date.
52
+
53
+ Args:
54
+ package: Name of the Python package.
55
+
56
+ Returns:
57
+ 0 if success.
58
+
59
+ """
60
+ if res := check_package(package):
61
+ print(res)
62
+ return 1
63
+ return 0
64
+
65
+
66
+ Take a closer look at the different example CLIs in the tests package that demonstrate the various features.
67
+
68
+
69
+ Documentation
70
+ =============
71
+
72
+ Read the `documentation <https://ternaris.gitlab.io/declinate/>`_ for further information.
73
+
74
+ .. end documentation
75
+
76
+
77
+ Contributing
78
+ ============
79
+
80
+ Thank you for considering to contribute to declinate.
81
+
82
+ To submit issues or create merge requests please follow the instructions provided in the `contribution guide <https://gitlab.com/ternaris/declinate/-/blob/master/CONTRIBUTING.rst>`_.
83
+
84
+ By contributing to declinate you accept and agree to the terms and conditions laid out in there.
85
+
86
+
87
+ Development
88
+ ===========
89
+
90
+ Clone the repository and setup your local checkout::
91
+
92
+ git clone https://gitlab.com/ternaris/declinate.git
93
+
94
+ cd declinate
95
+ python -m venv venv
96
+ . venv/bin/activate
97
+
98
+ pip install -r requirements-dev.txt
99
+ pip install -e .
100
+
101
+
102
+ This creates a new virtual environment with the necessary python dependencies and installs declinate in editable mode. The declinate code base uses pytest as its test runner, run the test suite by simply invoking::
103
+
104
+ pytest
105
+
106
+
107
+ To build the documentation from its source run sphinx-build::
108
+
109
+ sphinx-build -a docs public
110
+
111
+
112
+ The entry point to the local documentation build should be available under ``public/index.html``.
113
+
114
+
115
+ Support
116
+ =======
117
+
118
+ Professional support is available from `Ternaris <https://ternaris.com>`_.
@@ -0,0 +1 @@
1
+ .. include:: ../CHANGES.rst