More Click

0.1.3 · active · verified Thu Apr 16

More Click (more-click) is a Python library, currently at version 0.1.3, that provides implementations of common Command Line Interface (CLI) patterns built on top of the popular Click framework. It offers pre-defined options, web application integration utilities, and other conveniences to reduce boilerplate when developing Click-based CLIs. The library is actively maintained, with a focus on enhancing existing Click applications.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `more-click`'s `make_web_command` to integrate a Flask application into a Click CLI, and how to use a pre-defined option like `verbose_option` alongside custom Click options. Remember to replace 'my_package.wsgi:app' with the actual path to your Flask application instance.

import click
from more_click import make_web_command, verbose_option

# Example of a simple web command using more-click's utility
web_command = make_web_command('my_package.wsgi:app') # Replace 'my_package.wsgi:app' with your actual Flask app import path

@click.group()
def cli():
    pass

@cli.command()
@verbose_option
@click.option('--custom-flag', is_flag=True, help='A custom flag.')
def my_tool(verbose: bool, custom_flag: bool):
    """A command demonstrating more-click options and custom logic."""
    if verbose:
        click.echo("Verbose mode enabled.")
    if custom_flag:
        click.echo("Custom flag enabled.")
    click.echo("Running my_tool.")

cli.add_command(web_command, name='web') # Add the web command to your CLI group

if __name__ == '__main__':
    # To run the web command: python your_cli.py web --host 0.0.0.0 --port 8000
    # To run my_tool: python your_cli.py my-tool -v --custom-flag
    cli()

view raw JSON →