Skip to main content

A collection of command line helper scripts wrapping tools used during Python development.

Project description

🧰  Delfino  🧰

A collection of command line helper scripts wrapping tools used during Python development.

CircleCI Codecov GitHub tag (latest SemVer) Maintenance GitHub last commit PyPI - Python Version Downloads

Table of content

Installation

  • pip: pip install delfino
  • Poetry: poetry add -D delfino
  • Pipenv: pipenv install -d delfino

or

  • pip: pip install delfino[completion]
  • Poetry: poetry add -D delfino[completion]
  • Pipenv: pipenv install -d delfino[completion]

to enable auto-completion.

Optional dependencies

Each project may use different sub-set of commands. Therefore, dependencies of all commands are optional and checked only when the command is executed.

Using [all] installs all the optional dependencies used by all the built-in commands. If you want only a sub-set of those dependencies, there are finer-grained groups available:

  • For top-level parameters:
    • completion - for --show-completion and --install-completion
  • For individual commands (matches the command names):
    • upload_to_pypi
    • build_docker
    • typecheck
    • format
  • For groups of commands:
    • test - for testing and coverage commands
    • lint - for all the linting commands
  • For groups of groups:
    • verify_all - same as [typecheck,format,test,lint]
    • all - all optional packages

Configuration

Delfino will assume certain project structure. However, you can customize it to match your own by overriding the default values in the pyproject.toml file. Here are the defaults that you can modify:

[tool.delfino]
reports_directory = "reports"
sources_directory = "src"
tests_directory = "tests"
local_commands_directory = "commands"
test_types = ["unit", "integration"]
verify_commands = ["format", "lint", "typecheck", "test-all"]
disable_pre_commit = false

[tool.delfino.typecheck]
strict_directories = ['src']

# By default, all commands will be enabled. Use `enable_commands` or `disable_commands` 
# to show only a subset of commands. If both used, disabled commands are subtracted 
# from the set of enabled commands. 
# [tool.delfino.plugins.<PLUGIN_NAME_A>]
# enable_commands = [<COMMAND_NAME>]
# disable_commands = [<COMMAND_NAME>]
# [tool.delfino.plugins.<PLUGIN_NAME_B>]
# enable_commands = [<COMMAND_NAME>]
# disable_commands = [<COMMAND_NAME>]

# You can pass additional arguments to commands per project
# See https://github.com/radeklat/delfino/blob/main/src/delfino/commands/pass_args.py for usage.
# [tool.delfino.plugins.<PLUGIN>.<COMMAND>]
# pass_args = '--capture=no'

[tool.delfino.dockerhub]
username = ""
build_for_platforms = [
    "linux/amd64",
    "linux/arm64",
    "linux/arm/v7",
]

Usage

Run delfino --help to see all available commands and their usage.

Auto-completion

You can either attempt to install completions automatically with:

delfino --install-completion

or generate it with:

delfino --show-completion

and manually put it in the relevant RC file.

The auto-completion implementation is dynamic so that every time it is invoked, it uses the current project. Each project can have different commands or disable certain commands it doesn't use. And dynamic auto-completion makes sure only the currently available commands will be suggested.

The downside of this approach is that evaluating what is available each time is slower than a static list of commands.

Development

Delfino is a simple wrapper around Click. It allows you to add custom, project-specific commands. Let's call them Delfino commands or just commands. Commands are expected in the root of the project, in a Python package called commands. Any sub-class of click.Command in any .py file in this folder will be automatically used by Delfino.

Minimal command

  1. Create the commands package:
    mkdir commands
    touch commands/__init__.py
    
  2. Create a file commands/command_test.py, with the following content:
    import click
    
    @click.command()
    def command_test():
        """Tests commands placed in the `commands` folder are loaded."""
        print("✨ This command works! ✨")
    
  3. See if Delfino loads the command. Open a terminal and in the root of the project, call: delfino --help. You should see something like this:
    Usage: delfino [OPTIONS] COMMAND [ARGS]...
    
    Options:
      --help  Show this message and exit.
    
    Commands:
      ...
      command-test            Tests commands placed in the `commands` folder...
      ...
    
  4. Run the command with delfino command-test

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

delfino-0.27.0.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

delfino-0.27.0-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file delfino-0.27.0.tar.gz.

File metadata

  • Download URL: delfino-0.27.0.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.7.16 Linux/5.15.0-1021-aws

File hashes

Hashes for delfino-0.27.0.tar.gz
Algorithm Hash digest
SHA256 64be52f7d1ef0dc7a86c7d888d896f70bee9752707da11f174186e64e5ded372
MD5 1b942238c09a33abbe89a201854af140
BLAKE2b-256 0e6eee34eb6e41c913750ba4fadf9682a7a6ab355b7607e26d67fe90ead62f8c

See more details on using hashes here.

File details

Details for the file delfino-0.27.0-py3-none-any.whl.

File metadata

  • Download URL: delfino-0.27.0-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.7.16 Linux/5.15.0-1021-aws

File hashes

Hashes for delfino-0.27.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d90379964f8096ea9fc321295c6a7985a7b23f4a91f8b3a2ef5caa0f3e7d396
MD5 53ea5bf42e142a81a50f1b5676e8f2ac
BLAKE2b-256 7e35f4832d68fd8dcc4df6688b075298564de5c296af50950331ff6b02201b1f

See more details on using hashes here.

Supported by

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