Skip to main content

Generate click commands from your project

Project description

CliSync

A python package to sync module and command line tools.

Installation

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 directory. A readme file is available to explain how to install and use the demo.

Include all class methods

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}'
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.

import clisync
class Object():

    @staticmethod
    @clisync.include
    def method():
        """
        This method is included because of the decorator.
        """
        pass
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 file and in the 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:

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clisync-1.3.2.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clisync-1.3.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file clisync-1.3.2.tar.gz.

File metadata

  • Download URL: clisync-1.3.2.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for clisync-1.3.2.tar.gz
Algorithm Hash digest
SHA256 77cb678b72cb1d86909b92c26cde9b3dab2a7a169ab3b33d270b129697f3dec5
MD5 bdc2a47b4d0768e547e7191cf36fba68
BLAKE2b-256 9694695828228eee7a9da944538f152238de79dbb0ec55cf16318e68ec167ef9

See more details on using hashes here.

File details

Details for the file clisync-1.3.2-py3-none-any.whl.

File metadata

  • Download URL: clisync-1.3.2-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for clisync-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 98ae926439b409671fb1f5afab5544df0bc5819c2b809bf9b75cc2b1e18cad1c
MD5 3088f32e816c4075455b426098d4dec4
BLAKE2b-256 1091168333f75e8a5747b51cdffc3277da72e63ebec6ba495a07e1bb2f5e7d43

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page