# CliSync
A python package to sync module and command line tools.
- [CliSync](#clisync)
- [Installation](#installation)
- [Usage](#usage)
- [Include all class methods](#include-all-class-methods)
- [Specify the method to include](#specify-the-method-to-include)
- [Distribution on pypi](#distribution-on-pypi)
- [Changelog](#changelog)
## Installation
```bash
pip install clisync
```
## Usage
This package is used to create a command line tool from a module. The command line tool is created using the `click` package.
It is intended for a specific use case with singleton classes. The static methods of the class are included in the command line tool.
A working and complete demo is available in the [demo](demo) directory. A readme file is available to explain how to install and use the demo.
### Include all class methods
```python
class Object():
@staticmethod
def create(a: int, b: str, c: Optional[float] = 1.0) -> str:
"""
This is a docstring for the create method.
"""
return f'{a} {b} {c}'
```
```python
from clisync import CliSync
cli = CliSync(module='my_module', cls='Object', requires_decorator=False)
```
The `cli` is a `click.MultiCommand` object that can be used to create a command line tool.
### Specify the method to include
Use the decorator `@clisync.include` to include a method in the command line tool.
```python
import clisync
class Object():
@staticmethod
@clisync.include
def method():
"""
This method is included because of the decorator.
"""
pass
```
```python
from clisync import CliSync
cli = CliSync(module='my_module', cls='Object')
```
## Distribution on pypi
> Make sure the version number is updated in the [__init__.py](clisync/__init__.py) file and in the [setup.py](setup.py) file.
The distribution on done with continuous integration using github actions. The secret `PYPI_API_TOKEN` is set in the repository settings.
Then, to trigger the release, we need to create a tag with the version number. The release will be automatically created and the package will be uploaded to pypi.
For example, to release version 1.0.0, we need to do the following:
```bash
git tag v1.0.0
git push origin v1.0.0
```
You can also create a release with a new tag in the github interface.
## Changelog
- 1.2.0: Add the set up script for auto-complete using the `setup_autocomplete` function.
- 1.1.0: Add the possibility to exclude methods from the command line tool using the decorator `@clisync.exclude()`.
- 1.0.0: Initial release
Raw data
{
"_id": null,
"home_page": "https://clisync.surge.sh",
"name": "clisync",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "pip requirements imports",
"author": "Edward Laurence",
"author_email": "edwardl@hectiq.ai",
"download_url": "https://files.pythonhosted.org/packages/96/94/695828228eee7a9da944538f152238de79dbb0ec55cf16318e68ec167ef9/clisync-1.3.2.tar.gz",
"platform": null,
"description": "# CliSync\n\nA python package to sync module and command line tools.\n\n- [CliSync](#clisync)\n - [Installation](#installation)\n - [Usage](#usage)\n - [Include all class methods](#include-all-class-methods)\n - [Specify the method to include](#specify-the-method-to-include)\n - [Distribution on pypi](#distribution-on-pypi)\n - [Changelog](#changelog)\n\n## Installation\n\n```bash\npip install clisync\n```\n\n## Usage\nThis package is used to create a command line tool from a module. The command line tool is created using the `click` package.\n\nIt is intended for a specific use case with singleton classes. The static methods of the class are included in the command line tool.\n\nA working and complete demo is available in the [demo](demo) directory. A readme file is available to explain how to install and use the demo.\n\n### Include all class methods\n\n```python\nclass Object():\n\n @staticmethod\n def create(a: int, b: str, c: Optional[float] = 1.0) -> str:\n \"\"\"\n This is a docstring for the create method.\n \"\"\"\n return f'{a} {b} {c}'\n```\n\n```python\nfrom clisync import CliSync\ncli = CliSync(module='my_module', cls='Object', requires_decorator=False)\n```\n\nThe `cli` is a `click.MultiCommand` object that can be used to create a command line tool.\n\n### Specify the method to include\n\nUse the decorator `@clisync.include` to include a method in the command line tool.\n\n```python\nimport clisync\nclass Object():\n\n @staticmethod\n @clisync.include\n def method():\n \"\"\"\n This method is included because of the decorator.\n \"\"\"\n pass\n```\n\n```python\nfrom clisync import CliSync\ncli = CliSync(module='my_module', cls='Object')\n```\n\n## Distribution on pypi\n\n> Make sure the version number is updated in the [__init__.py](clisync/__init__.py) file and in the [setup.py](setup.py) file.\n\nThe distribution on done with continuous integration using github actions. The secret `PYPI_API_TOKEN` is set in the repository settings.\n\nThen, to trigger the release, we need to create a tag with the version number. The release will be automatically created and the package will be uploaded to pypi.\n\nFor example, to release version 1.0.0, we need to do the following:\n\n```bash\ngit tag v1.0.0\ngit push origin v1.0.0\n``` \n\nYou can also create a release with a new tag in the github interface.\n\n## Changelog\n\n- 1.2.0: Add the set up script for auto-complete using the `setup_autocomplete` function.\n- 1.1.0: Add the possibility to exclude methods from the command line tool using the decorator `@clisync.exclude()`.\n- 1.0.0: Initial release\n",
"bugtrack_url": null,
"license": null,
"summary": "Generate click commands from your project",
"version": "1.3.2",
"project_urls": {
"Homepage": "https://clisync.surge.sh"
},
"split_keywords": [
"pip",
"requirements",
"imports"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1091168333f75e8a5747b51cdffc3277da72e63ebec6ba495a07e1bb2f5e7d43",
"md5": "3088f32e816c4075455b426098d4dec4",
"sha256": "98ae926439b409671fb1f5afab5544df0bc5819c2b809bf9b75cc2b1e18cad1c"
},
"downloads": -1,
"filename": "clisync-1.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3088f32e816c4075455b426098d4dec4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7261,
"upload_time": "2024-06-18T19:07:11",
"upload_time_iso_8601": "2024-06-18T19:07:11.497078Z",
"url": "https://files.pythonhosted.org/packages/10/91/168333f75e8a5747b51cdffc3277da72e63ebec6ba495a07e1bb2f5e7d43/clisync-1.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9694695828228eee7a9da944538f152238de79dbb0ec55cf16318e68ec167ef9",
"md5": "bdc2a47b4d0768e547e7191cf36fba68",
"sha256": "77cb678b72cb1d86909b92c26cde9b3dab2a7a169ab3b33d270b129697f3dec5"
},
"downloads": -1,
"filename": "clisync-1.3.2.tar.gz",
"has_sig": false,
"md5_digest": "bdc2a47b4d0768e547e7191cf36fba68",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10073,
"upload_time": "2024-06-18T19:07:15",
"upload_time_iso_8601": "2024-06-18T19:07:15.198262Z",
"url": "https://files.pythonhosted.org/packages/96/94/695828228eee7a9da944538f152238de79dbb0ec55cf16318e68ec167ef9/clisync-1.3.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-18 19:07:15",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "clisync"
}