Skip to main content

Suppresses the default behavior of Click commands to exit the process.

Project description

click-noexit

A utility for the Click command-line interface library that prevents commands from exiting the application directly. Instead, it allows commands to return exit codes for improved control and handling in larger applications.

Introduction

click-noexit is a decorator for Click commands designed to suppress the default behavior of exiting the application upon command completion or when an error occurs. This is particularly useful when integrating Click commands into larger applications, where you want to handle exits and exceptions more gracefully.

Installation

Install click-noexit using pip:

pip install click-noexit

Or, if you are using Poetry:

poetry add click-noexit

Ensure that you have Click version 8.0.0 or newer.

Installation

Import and use the noexit decorator to wrap your Click commands:

import click
import click_noexit

@click_noexit.noexit()
@click.command()
def my_command():
    # Command logic here
    pass

The noexit decorator can be used without any additional arguments. It modifies the behavior of the Click command to prevent the application from exiting and allows the command to return exit codes instead.

Examples

Basic Command

@click_noexit.noexit()
@click.command()
def hello() -> None:
    click.echo("Hello, World!")

Command with Exit Code

@noexit()
@click.command()
def goodbye():
    click.echo("Goodbye!")
    return 42

Contributing

Contributions are welcome! If you have a feature request, bug report, or a pull request, please feel free to open an issue or a pull request on the project repository.

License

click-noexit is released under the MIT License. See the LICENSE file for more details.

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

click_noexit-0.1.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

click_noexit-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file click_noexit-0.1.0.tar.gz.

File metadata

  • Download URL: click_noexit-0.1.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for click_noexit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cc22f2e6fc9d2f9a3e09faea34db04ea8843345c26bc29e6b367c3302c1d0c96
MD5 56fcfe2e279000d6f2a6338606ebe9da
BLAKE2b-256 c01466f398afda30794f9131b68a7d802b99e87e425af573fecaaee920eb6f99

See more details on using hashes here.

File details

Details for the file click_noexit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: click_noexit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for click_noexit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ab1050f8c9a12f3be638f853fa2f576de82ea94ca017c1f9da36ab8068d2e15
MD5 4d4e6dcb460dd9fc4fbabb9684e0df5f
BLAKE2b-256 1bbb8db760ab6a14d6d80b3b7b667c275760933dce4e8c3094f55b157484f463

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