feud


Namefeud JSON
Version 0.3.2 PyPI version JSON
download
home_pagehttps://github.com/eonu/feud
SummaryBuild powerful CLIs with simple idiomatic Python, driven by type hints. Not all arguments are bad.
upload_time2024-04-01 19:02:38
maintainerEdwin Onuonga
docs_urlNone
authorEdwin Onuonga
requires_python<4.0,>=3.11
licenseMIT
keywords python cli terminal command-line typed docstrings typehints pydantic click
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <h1 align="center">
    Feud
  </h1>
  <p align="center"><b>Not all arguments are bad.</b></p>
</p>

<img src="https://svgur.com/i/zk4.svg" align="right" width="100px">

<p align="center">
  <em>Build powerful CLIs with simple idiomatic Python, driven by type hints.</em>
</p>

<p align="center">
  <div align="center">
    <a href="https://pypi.org/project/feud">
      <img src="https://img.shields.io/pypi/v/feud?logo=pypi&style=flat-square" alt="PyPI"/>
    </a>
    <a href="https://pypi.org/project/feud">
      <img src="https://img.shields.io/pypi/pyversions/feud?logo=python&style=flat-square" alt="PyPI - Python Version"/>
    </a>
    <a href="https://feud.readthedocs.io/en/latest">
      <img src="https://img.shields.io/readthedocs/feud.svg?logo=read-the-docs&style=flat-square" alt="Read The Docs - Documentation"/>
    </a>
    <a href="https://coveralls.io/github/eonu/feud">
      <img src="https://img.shields.io/coverallsCoverage/github/eonu/feud?logo=coveralls&style=flat-square" alt="Coveralls - Coverage"/>
    </a>
    <a href="https://raw.githubusercontent.com/eonu/feud/master/LICENSE">
      <img src="https://img.shields.io/pypi/l/feud?style=flat-square" alt="PyPI - License"/>
    </a>
  </div>
</p>

<p align="center">
  <sup>
    <a href="#about">About</a> ·
    <a href="#features">Features</a> ·
    <a href="#installation">Installation</a> ·
    <a href="#build-status">Build status</a> ·
    <a href="#documentation">Documentation</a> ·
    <a href="#related-projects">Related projects</a> ·
    <a href="#contributing">Contributing</a> ·
    <a href="#licensing">Licensing</a>
  </sup>
</p>

## About

Designing a _good_ CLI can quickly spiral into chaos without the help of
an intuitive CLI framework.

**Feud builds on [Click](https://click.palletsprojects.com/en/8.1.x/) for
argument parsing, along with [Pydantic](https://docs.pydantic.dev/latest/)
for typing, to make CLI building a breeze.**

## Features

### Simplicity

Click is often considered the defacto command-line building utility for Python –
offering far more functionality and better ease-of-use than the standard
library's [`argparse`](https://docs.python.org/3/library/argparse.html).
Despite this, for even the simplest of CLIs, code written using Click can be
somewhat verbose and often requires frequently looking up documentation.

Consider the following example command for serving local files on a HTTP server.

**In red is a typical Click implementation, and in green is the Feud equivalent.**

<table>
<tr>
<td>

**Example**: Command for running a HTTP web server.

</td>
</tr>
<tr>
<td>

```diff
# serve.py

- import click
+ import feud
+ from typing import Literal

- @click.command
- @click.argument("port", type=int, help="Server port.")
- @click.option("--watch/--no-watch", type=bool, default=True, help="Watch source code for changes.")
- @click.option("--env", type=click.Choice(["dev", "prod"]), default="dev", help="Environment mode.")
- def serve(port, watch, env):
+ def serve(port: int, *, watch: bool = True, env: Literal["dev", "prod"] = "dev"):
-     """Start a local HTTP server."""
+     """Start a local HTTP server.
+
+     Parameters
+     ----------
+     port:
+         Server port.
+     watch:
+         Watch source code for changes.
+     env:
+         Environment mode.
+     """

if __name__ == "__main__":
-     serve()
+     feud.run(serve)
```

</td>
</tr>
<tr>
<td>
<details>
  <summary>
    <b>Click here to view the generated help screen.</b>
  </summary>
<p>

Help screen for the `serve` command.

```console
$ python serve.py --help

 Usage: serve.py [OPTIONS] PORT

 Start a local HTTP server.

╭─ Arguments ────────────────────────────────────────────────────────╮
│ *  PORT    INTEGER  [required]                                     │
╰────────────────────────────────────────────────────────────────────╯
╭─ Options ──────────────────────────────────────────────────────────╮
│ --watch/--no-watch                Watch source code for changes.   │
│                                   [default: watch]                 │
│ --env                 [dev|prod]  Environment mode. [default: dev] │
│ --help                            Show this message and exit.      │
╰────────────────────────────────────────────────────────────────────╯
```

</p>
</details>
</td>
</tr>
<tr>
<td>
<details>
  <summary>
    <b>Click here to see usage examples.</b>
  </summary>
<p>

- `python serve.py 8080`
- `python serve.py 3000 --watch --env dev`
- `python serve.py 4567 --no-watch --env prod`

</p>
</details>
</td>
</tr>
</table>

The core design principle behind Feud is to make it as easy as possible
for even beginner Python developers to quickly create sophisticated CLIs.

The above function is written in idiomatic Python, adhering to language
standards and using basic core language features such as type hints and
docstrings to declare all of the relevant information about the CLI,
but relying on Feud to carry out the heavy lifting of converting these
language elements into a fully-fledged CLI.

#### Grouping commands

While a single command is often all that you need, Feud makes it
straightforward to logically group together related commands into a _group_
represented by a class with commands defined within it.

<table>
<tr>
<td>

**Example**: Commands for creating, deleting and listing blog posts.

</td>
</tr>
<tr>
<td>

```python
# post.py

import feud
from datetime import date

class Post(feud.Group):
    """Manage blog posts."""

    def create(id: int, *, title: str, desc: str | None = None):
        """Create a blog post."""

    def delete(*ids: int):
        """Delete blog posts."""

    def list(*, between: tuple[date, date] | None = None):
        """View all blog posts, optionally filtering by date range."""

if __name__ == "__main__":
    feud.run(Post)
```

</td>
</tr>
<tr>
<td>
<details>
  <summary>
    <b>Click here to view the generated help screen.</b>
  </summary>
<p>

Help screen for the `post` group.

```console
$ python post.py --help

 Usage: post.py [OPTIONS] COMMAND [ARGS]...

 Manage blog posts.

╭─ Options ──────────────────────────────────────────────────────────╮
│ --help      Show this message and exit.                            │
╰────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────╮
│ create   Create a blog post.                                       │
│ delete   Delete blog posts.                                        │
│ list     View all blog posts, optionally filtering by date range.  │
╰────────────────────────────────────────────────────────────────────╯
```

Help screen for the `list` command within the `post` group.

```console
$ python post.py list --help

 Usage: post.py list [OPTIONS]

 View all blog posts, optionally filtering by date range.

╭─ Options ──────────────────────────────────────────────────────────╮
│ --between    <DATE DATE>...                                        │
│ --help                       Show this message and exit.           │
╰────────────────────────────────────────────────────────────────────╯
```

</p>
</details>
</td>
</tr>
<tr>
<td>
<details>
  <summary>
    <b>Click here to see usage examples.</b>
  </summary>
<p>

- `python post.py create 1 --title "My First Post"`
- `python post.py create 2 --title "My First Detailed Post" --desc "Hi!"`
- `python post.py delete 1 2`
- `python post.py list`
- `python post.py list --between 2020-01-30 2021-01-30`

</p>
</details>
</td>
</tr>
</table>

Alternatively, if you already have some functions defined that you would like
to run as commands, you can simply provide them to `feud.run` and it will
automatically generate and run a group with those commands.

```python
# post.py

import feud
from datetime import date

def create_post(id: int, *, title: str, desc: str | None = None):
    """Create a blog post."""

def delete_posts(*ids: int):
    """Delete blog posts."""

def list_posts(*, between: tuple[date, date] | None = None):
    """View all blog posts, optionally filtering by date range."""

if __name__ == "__main__":
    feud.run([create_post, delete_posts, list_posts])
```

You can also use a `dict` to rename the generated commands:

```python
feud.run({"create": create_post, "delete": delete_posts, "list": list_posts})
```

For more complex applications, you can also nest commands in sub-groups:

```python
feud.run({"list": list_posts, "modify": [create_post, delete_posts]})
```

If commands are defined in another module, you can also
run the module directly and Feud will pick up all runnable objects:

```python
import post

feud.run(post)
```

You can even call `feud.run()` without providing any object, and it will
automatically discover all runnable objects in the current module.

_As you can see, building a CLI using Feud does not require learning many new
magic methods or a domain-specific language – you can just use the simple
Python you know and ❤️!_

#### Registering command sub-groups

Groups can be registered as sub-groups under other groups. This is a common
pattern in CLIs, allowing for interfaces packed with lots of functionality,
but still organized in a sensible way.

<table>
<tr>
<td>

**Example**: CLI with the following structure for running and managing a blog.

- **`blog`**: Group to manage and serve a blog.
  - `serve`: Command to run the blog HTTP server.
  - **`post`**: Sub-group to manage blog posts.
    - `create`: Command to create a blog post.
    - `delete`: Command to delete blog posts.
    - `list`: Command to view all blog posts.

</td>
</tr>
<tr>
<td>

```python
# blog.py

import feud
from datetime import date
from typing import Literal

class Blog(feud.Group):
    """Manage and serve a blog."""

    def serve(port: int, *, watch: bool = True, env: Literal["dev", "prod"] = "dev"):
        """Start a local HTTP server."""

class Post(feud.Group):
    """Manage blog posts."""

    def create(id: int, *, title: str, desc: str | None = None):
        """Create a blog post."""

    def delete(*ids: int):
        """Delete blog posts."""

    def list(*, between: tuple[date, date] | None = None):
        """View all blog posts, optionally filtering by date range."""

Blog.register(Post)

if __name__ == "__main__":
    feud.run(Blog)
```

</td>
</tr>
<tr>
<td>

<details>
  <summary>
    <b>Click here to view the generated help screen.</b>
  </summary>
<p>

Help screen for the `blog` group.

```console
$ python blog.py --help

 Usage: blog.py [OPTIONS] COMMAND [ARGS]...

 Manage and serve a blog.

╭─ Options ──────────────────────────────────────────────────────────╮
│ --help      Show this message and exit.                            │
╰────────────────────────────────────────────────────────────────────╯
╭─ Command groups ───────────────────────────────────────────────────╮
│ post         Manage blog posts.                                    │
╰────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────╮
│ serve        Start a local HTTP server.                            │
╰────────────────────────────────────────────────────────────────────╯
```

Help screen for the `serve` command in the `blog` group.

```console
$ python blog.py serve --help

 Usage: blog.py serve [OPTIONS] PORT

 Start a local HTTP server.

╭─ Arguments ────────────────────────────────────────────────────────╮
│ *  PORT    INTEGER  [required]                                     │
╰────────────────────────────────────────────────────────────────────╯
╭─ Options ──────────────────────────────────────────────────────────╮
│ --watch/--no-watch                [default: watch]                 │
│ --env                 [dev|prod]  [default: dev]                   │
│ --help                            Show this message and exit.      │
╰────────────────────────────────────────────────────────────────────╯
```

Help screen for the `post` sub-group in the `blog` group.

```console
$ python blog.py post --help

 Usage: blog.py post [OPTIONS] COMMAND [ARGS]...

 Manage blog posts.

╭─ Options ──────────────────────────────────────────────────────────╮
│ --help      Show this message and exit.                            │
╰────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────╮
│ create   Create a blog post.                                       │
│ delete   Delete blog posts.                                        │
│ list     View all blog posts, optionally filtering by date range.  │
╰────────────────────────────────────────────────────────────────────╯
```

Help screen for the `list` command within the `post` sub-group.

```console
$ python blog.py post list --help

 Usage: blog.py post list [OPTIONS]

 View all blog posts, optionally filtering by date range.

╭─ Options ──────────────────────────────────────────────────────────╮
│ --between    <DATE DATE>...                                        │
│ --help                       Show this message and exit.           │
╰────────────────────────────────────────────────────────────────────╯
```

</p>
</details>

</td>
</tr>
<tr>
<td>
<details>
  <summary>
    <b>Click here to see usage examples.</b>
  </summary>
<p>

- `python blog.py serve 8080 --no-watch --env prod`
- `python blog.py post create 1 --title "My First Post!"`
- `python blog.py post list --between 2020-01-30 2021-01-30`

</p>
</details>
</td>
</tr>
</table>

### Powerful typing

Feud is powered by [Pydantic](https://docs.pydantic.dev/latest/) – a
validation library with extensive support for many data types, including:

- simple types such as integers and dates,
- complex types such as emails, IP addresses, file/directory paths, database
  connection strings,
- constrained types (e.g. positive/negative integers or past/future dates).

[`pydantic-extra-types`](https://github.com/pydantic/pydantic-extra-types) is
an optional dependency offering additional types such as country names,
payment card numbers, phone numbers, colours, latitude/longitude and more.

Custom annotated types with user-defined validation functions can also be
defined with Pydantic.

<table>
<tr>
<td>

**Example**: Command for generating audio samples from text prompts using
a machine learning model, and storing produced audio files in an output
directory.

- **At least one** text prompt must be provided.
- **No more than five** text prompts can be provided.
- Each text prompt can have a **maximum of 12 characters**.
- The model is specified by a path to a **file that must exist**.
- The output directory is a path to a **folder that must exist**.

</td>
</tr>
<tr>
<td>

```python
# generate.py

import feud
from pydantic import FilePath, DirectoryPath, conlist, constr

def generate(
    prompts: conlist(constr(max_length=12), min_length=1, max_length=5),
    *,
    model: FilePath,
    output: DirectoryPath,
):
    """Generates audio from prompts using a trained model."""

if __name__ == "__main__":
    feud.run(generate)
```

</td>
</tr>
<tr>
<td>
<details>
  <summary>
    <b>Click here to view the generated help screen.</b>
  </summary>
<p>

Help screen for the `generate` command.

```console
$ python generate.py --help

 Usage: generate.py [OPTIONS] [PROMPTS]...

 Generates audio from prompts using a trained model.

╭─ Arguments ────────────────────────────────────────────────────────╮
│ PROMPTS    TEXT                                                    │
╰────────────────────────────────────────────────────────────────────╯
╭─ Options ──────────────────────────────────────────────────────────╮
│ *  --model     FILE       [required]                               │
│ *  --output    DIRECTORY  [required]                               │
│    --help                 Show this message and exit.              │
╰────────────────────────────────────────────────────────────────────╯
```

</p>
</details>
</td>
</tr>
<tr>
<td>
<details>
  <summary>
    <b>Click here to see usage examples.</b>
  </summary>
<p>

If we run the script without prompts, we get an error that at least one prompt
must be provided.

```console
$ python generate.py --model models/real_model.pt --output audio/

 Usage: generate.py [OPTIONS] [PROMPTS]...

 Try 'generate.py --help' for help
╭─ Error ──────────────────────────────────────────────────────────────────────╮
│ 1 validation error for command 'generate'                                    │
│ [PROMPTS]...                                                                 │
│   List should have at least 1 item after validation, not 0 [input_value=()]  │
╰──────────────────────────────────────────────────────────────────────────────╯
```

If we provide a prompt longer than 12 characters, we also get an error.

```console
$ python generate.py "dog barking" "cat meowing" "fish blubbing" --model models/real_model.pt --output audio/

 Usage: generate.py [OPTIONS] [PROMPTS]...

 Try 'generate.py --help' for help
╭─ Error ──────────────────────────────────────────────────────────────────────╮
│ 1 validation error for command 'generate'                                    │
│ [PROMPTS]... [2]                                                             │
│   String should have at most 12 characters [input_value='fish blubbing']     │
╰──────────────────────────────────────────────────────────────────────────────╯
```

`FilePath` indicates that the file must already exist, so we get an error if we
provide a non-existent file.

```console
$ python generate.py "dog barking" "cat meowing" --model models/fake_model.pt

 Usage: generate.py [OPTIONS] [PROMPTS]...

 Try 'generate.py --help' for help
╭─ Error ──────────────────────────────────────────────────────────────────────╮
│ Invalid value for '--model': File 'models/fake_model.pt' does not exist.     │
╰──────────────────────────────────────────────────────────────────────────────╯
```

`DirectoryPath` indicates that the path must be a directory, so we
get an error if we provide a file.

```console
$ python generate.py "dog barking" "cat meowing" --output audio.txt

 Usage: generate.py [OPTIONS] [PROMPTS]...

 Try 'generate.py --help' for help
╭─ Error ──────────────────────────────────────────────────────────────────────╮
│ Invalid value for '--output': Directory 'audio.txt' is a file.               │
╰──────────────────────────────────────────────────────────────────────────────╯
```

</p>
</details>
</td>
</tr>
</table>

_By relying on Pydantic to handle the hard work of validation, we can contain all
of the required CLI constraints in a simple function signature, leaving you to focus
on the important part – implementing your commands._

### Highly configurable and extensible

While designed to be simpler than Click, this comes with the trade-off that
Feud is also more opinionated than Click and only directly implements a subset
of its functionality.

However, Feud was designed to allow for Click to seamlessly slot in whenever
manual overrides are necessary.

<table>
<tr>
<td>

**Example**: Use [`click.password_option`](https://click.palletsprojects.com/en/8.1.x/api/#click.password_option)
to securely prompt the user for a password, but still validate based on the
type hint (length should be ≥ 10 characters).

</td>
</tr>
<tr>
<td>

```python
# login.py

import feud
from feud import click
from pydantic import constr

@click.password_option("--password", help="The user's password (≥ 10 characters).")
def login(*, username: str, password: constr(min_length=10)):
    """Log in as a user.

    Parameters
    ----------
    username:
        The user's username.
    """

if __name__ == "__main__":
    feud.run(login)
```

</td>
</tr>
<tr>
<td>
<details>
  <summary>
    <b>Click here to view the generated help screen.</b>
  </summary>
<p>

Help screen for the `login` command.

```console
$ python login.py --help

 Usage: login.py [OPTIONS]

 Log in as a user.

╭─ Options ──────────────────────────────────────────────────────────╮
│ *  --username    TEXT  The user's username. [required]             │
│    --password    TEXT  The user's password (≥ 10 characters).      │
│    --help              Show this message and exit.                 │
╰────────────────────────────────────────────────────────────────────╯
```

</p>
</details>
</td>
</tr>
<tr>
<td>
<details>
  <summary>
    <b>Click here to see usage examples.</b>
  </summary>
<p>

```console
$ python login.py --username alice

Password: ***
Repeat for confirmation: ***

 Usage: login.py [OPTIONS]

 Try 'login.py --help' for help
╭─ Error ────────────────────────────────────────────────────────────╮
│ 1 validation error for command 'login'                             │
│ --password                                                         │
│   String should have at least 10 characters [input_value=hidden]   │
╰────────────────────────────────────────────────────────────────────╯
```

</p>
</detail>
</td>
</tr>
</table>

## Installation

You can install Feud using `pip`.

The latest stable version of Feud can be installed with the following command.

```console
pip install "feud[all]"
```

This installs Feud with the optional dependencies:

- [`rich-click`](https://github.com/ewels/rich-click) (can install individually with `pip install "feud[rich]"`)<br/>
  _Provides improved formatting for CLIs produced by Feud._
- [`pydantic-extra-types`](https://github.com/pydantic/pydantic-extra-types) (can install individually with `pip install "feud[extra-types]"`)<br/>
  _Provides additional types that can be used as type hints for Feud commands._
- [`email-validator`](https://github.com/JoshData/python-email-validator) (can install individually with `pip install "feud[email]"`)<br/>
  _Provides Pydantic support for email validation._

To install Feud without any optional dependencies, simply run `pip install feud`.

> [!CAUTION]
> Feud **will break** if used with postponed type hint evaluation ([PEP563](https://peps.python.org/pep-0563/)), i.e.:
>
> ```python
> from __future__ import annotations
> ```
>
> This is because Feud relies on type hint evaluation in order to determine the expected input type for command parameters.

### Improved formatting with Rich

Below is a comparison of Feud with and without `rich-click`.

<table>
<tr>
<th>
With Rich-formatted output
</th>
<th>
Without Rich-formatted output
</th>
</tr>
<tr>
<td>
<img src="/docs/source/_static/images/readme/help-rich.png"/>
</td>
<td>
<img src="/docs/source/_static/images/readme/help-no-rich.png"/>
</td>
</tr>
<tr>
<td>
<img src="/docs/source/_static/images/readme/error-rich.png"/>
</td>
<td>
<img src="/docs/source/_static/images/readme/error-no-rich.png"/>
</td>
</tr>
</table>

## Build status

| `master`                                                                                                                                                                                       | `dev`                                                                                                                                                                                            |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [![CircleCI Build (Master)](https://img.shields.io/circleci/build/github/eonu/feud/master?logo=circleci&style=flat-square)](https://app.circleci.com/pipelines/github/eonu/feud?branch=master) | [![CircleCI Build (Development)](https://img.shields.io/circleci/build/github/eonu/feud/dev?logo=circleci&style=flat-square)](https://app.circleci.com/pipelines/github/eonu/feud?branch=master) |

## Documentation

- [API reference](https://docs.feud.wiki):
  Library documentation for public modules, classes and functions.

<!--
- [Official website](https://feud.wiki):
  High level information about the package.
- [User guide](https://feud.wiki/guide):
  Detailed walkthrough of features, with examples of both simple and complex
  usage patterns.
-->

## Related projects

Feud either relies heavily on, or was inspired by the following
packages. It would be greatly appreciated if you also supported the below
maintainers and the work they have done that Feud has built upon.

<table>

<tr>
  <th>Project</th>
  <th>Description</th>
</tr>
<tr>
<td>

[**Click**](https://github.com/pallets/click)

<sup>

by&nbsp;[@pallets](https://github.com/pallets)

</sup>
  
</td>
<td>

Feud is essentially a wrapper around Click that takes classes and functions
with type hints and intelligently 'compiles' them into a ready-to-use Click
generated CLI.

</td>
</tr>
<tr>
<td>

[**Rich Click**](https://github.com/ewels/rich-click)

<sup>

by&nbsp;[@ewels](https://github.com/ewels)

</sup>

</td>
<td>

A shim around Click that renders help output nicely using
[Rich](https://github.com/Textualize/rich).

</td>
</tr>
<tr>
<td>

[**Pydantic**](https://github.com/pydantic/pydantic)

<sup>

by&nbsp;[@samuelcolvin](https://github.com/samuelcolvin)

</sup>

</td>
<td>

Pydantic is a validation package that makes it easy to declaratively validate
input data based on type hints.

The package offers support for common standard library types, plus more complex
types which can also be used as type hints in Feud commands for input validation.

</td>
</tr>
<tr>
<td>

[**Typer**](https://github.com/tiangolo/typer)

<sup>

by&nbsp;[@tiangolo](https://github.com/tiangolo)

</sup>

</td>
<td>

Typer shares a similar ideology to Feud, in that building CLIs should be
simple and not require learning new functions or constantly referring to
library documentation. Typer is also based on Click.

Typer is a more complete library for building CLIs overall, but currently
lacks support for more complex types such as those offered by Pydantic.

</td>
</tr>
<tr>
<td>

[**Thor**](https://github.com/rails/thor)

<sup>

by&nbsp;[@rails](https://github.com/rails)

</sup>

</td>
<td>

Though not a Python package, the highly object-oriented design of Thor (a CLI
building package in Ruby) – in particular the use of classes to define command
groups – greatly influenced the implementation of the `feud.Group` class.

</td>
</tr>

</table>

## Contributing

All contributions to this repository are greatly appreciated. Contribution guidelines can be found [here](/CONTRIBUTING.md).

> <img src="https://i.postimg.cc/jq3MZSTD/avatar.png" align="left"/>
> <b>We're living in an imperfect world!</b><br/>
> <sup>Feud is in a public beta-test phase, likely with <em>lots</em> of bugs. Please <a href="https://github.com/eonu/feud/issues/new/choose">leave feedback</a> if you come across anything strange!</sup>

## Licensing

Feud is released under the [MIT](https://opensource.org/licenses/MIT) license.

---

<p align="center">
  <b>Feud</b> &copy; 2023-2025, Edwin Onuonga - Released under the <a href="https://opensource.org/licenses/MIT">MIT</a> license.<br/>
  <em>Authored and maintained by Edwin Onuonga.</em>
</p>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/eonu/feud",
    "name": "feud",
    "maintainer": "Edwin Onuonga",
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": "ed@eonu.net",
    "keywords": "python, cli, terminal, command-line, typed, docstrings, typehints, pydantic, click",
    "author": "Edwin Onuonga",
    "author_email": "ed@eonu.net",
    "download_url": "https://files.pythonhosted.org/packages/74/78/55b9704bf5022caa4e3eeb0f8efe0c2e5e43d4f082e1ddba4122a4e45d80/feud-0.3.2.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n  <h1 align=\"center\">\n    Feud\n  </h1>\n  <p align=\"center\"><b>Not all arguments are bad.</b></p>\n</p>\n\n<img src=\"https://svgur.com/i/zk4.svg\" align=\"right\" width=\"100px\">\n\n<p align=\"center\">\n  <em>Build powerful CLIs with simple idiomatic Python, driven by type hints.</em>\n</p>\n\n<p align=\"center\">\n  <div align=\"center\">\n    <a href=\"https://pypi.org/project/feud\">\n      <img src=\"https://img.shields.io/pypi/v/feud?logo=pypi&style=flat-square\" alt=\"PyPI\"/>\n    </a>\n    <a href=\"https://pypi.org/project/feud\">\n      <img src=\"https://img.shields.io/pypi/pyversions/feud?logo=python&style=flat-square\" alt=\"PyPI - Python Version\"/>\n    </a>\n    <a href=\"https://feud.readthedocs.io/en/latest\">\n      <img src=\"https://img.shields.io/readthedocs/feud.svg?logo=read-the-docs&style=flat-square\" alt=\"Read The Docs - Documentation\"/>\n    </a>\n    <a href=\"https://coveralls.io/github/eonu/feud\">\n      <img src=\"https://img.shields.io/coverallsCoverage/github/eonu/feud?logo=coveralls&style=flat-square\" alt=\"Coveralls - Coverage\"/>\n    </a>\n    <a href=\"https://raw.githubusercontent.com/eonu/feud/master/LICENSE\">\n      <img src=\"https://img.shields.io/pypi/l/feud?style=flat-square\" alt=\"PyPI - License\"/>\n    </a>\n  </div>\n</p>\n\n<p align=\"center\">\n  <sup>\n    <a href=\"#about\">About</a> \u00b7\n    <a href=\"#features\">Features</a> \u00b7\n    <a href=\"#installation\">Installation</a> \u00b7\n    <a href=\"#build-status\">Build status</a> \u00b7\n    <a href=\"#documentation\">Documentation</a> \u00b7\n    <a href=\"#related-projects\">Related projects</a> \u00b7\n    <a href=\"#contributing\">Contributing</a> \u00b7\n    <a href=\"#licensing\">Licensing</a>\n  </sup>\n</p>\n\n## About\n\nDesigning a _good_ CLI can quickly spiral into chaos without the help of\nan intuitive CLI framework.\n\n**Feud builds on [Click](https://click.palletsprojects.com/en/8.1.x/) for\nargument parsing, along with [Pydantic](https://docs.pydantic.dev/latest/)\nfor typing, to make CLI building a breeze.**\n\n## Features\n\n### Simplicity\n\nClick is often considered the defacto command-line building utility for Python \u2013\noffering far more functionality and better ease-of-use than the standard\nlibrary's [`argparse`](https://docs.python.org/3/library/argparse.html).\nDespite this, for even the simplest of CLIs, code written using Click can be\nsomewhat verbose and often requires frequently looking up documentation.\n\nConsider the following example command for serving local files on a HTTP server.\n\n**In red is a typical Click implementation, and in green is the Feud equivalent.**\n\n<table>\n<tr>\n<td>\n\n**Example**: Command for running a HTTP web server.\n\n</td>\n</tr>\n<tr>\n<td>\n\n```diff\n# serve.py\n\n- import click\n+ import feud\n+ from typing import Literal\n\n- @click.command\n- @click.argument(\"port\", type=int, help=\"Server port.\")\n- @click.option(\"--watch/--no-watch\", type=bool, default=True, help=\"Watch source code for changes.\")\n- @click.option(\"--env\", type=click.Choice([\"dev\", \"prod\"]), default=\"dev\", help=\"Environment mode.\")\n- def serve(port, watch, env):\n+ def serve(port: int, *, watch: bool = True, env: Literal[\"dev\", \"prod\"] = \"dev\"):\n-     \"\"\"Start a local HTTP server.\"\"\"\n+     \"\"\"Start a local HTTP server.\n+\n+     Parameters\n+     ----------\n+     port:\n+         Server port.\n+     watch:\n+         Watch source code for changes.\n+     env:\n+         Environment mode.\n+     \"\"\"\n\nif __name__ == \"__main__\":\n-     serve()\n+     feud.run(serve)\n```\n\n</td>\n</tr>\n<tr>\n<td>\n<details>\n  <summary>\n    <b>Click here to view the generated help screen.</b>\n  </summary>\n<p>\n\nHelp screen for the `serve` command.\n\n```console\n$ python serve.py --help\n\n Usage: serve.py [OPTIONS] PORT\n\n Start a local HTTP server.\n\n\u256d\u2500 Arguments \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 *  PORT    INTEGER  [required]                                     \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\u256d\u2500 Options \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 --watch/--no-watch                Watch source code for changes.   \u2502\n\u2502                                   [default: watch]                 \u2502\n\u2502 --env                 [dev|prod]  Environment mode. [default: dev] \u2502\n\u2502 --help                            Show this message and exit.      \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\n</p>\n</details>\n</td>\n</tr>\n<tr>\n<td>\n<details>\n  <summary>\n    <b>Click here to see usage examples.</b>\n  </summary>\n<p>\n\n- `python serve.py 8080`\n- `python serve.py 3000 --watch --env dev`\n- `python serve.py 4567 --no-watch --env prod`\n\n</p>\n</details>\n</td>\n</tr>\n</table>\n\nThe core design principle behind Feud is to make it as easy as possible\nfor even beginner Python developers to quickly create sophisticated CLIs.\n\nThe above function is written in idiomatic Python, adhering to language\nstandards and using basic core language features such as type hints and\ndocstrings to declare all of the relevant information about the CLI,\nbut relying on Feud to carry out the heavy lifting of converting these\nlanguage elements into a fully-fledged CLI.\n\n#### Grouping commands\n\nWhile a single command is often all that you need, Feud makes it\nstraightforward to logically group together related commands into a _group_\nrepresented by a class with commands defined within it.\n\n<table>\n<tr>\n<td>\n\n**Example**: Commands for creating, deleting and listing blog posts.\n\n</td>\n</tr>\n<tr>\n<td>\n\n```python\n# post.py\n\nimport feud\nfrom datetime import date\n\nclass Post(feud.Group):\n    \"\"\"Manage blog posts.\"\"\"\n\n    def create(id: int, *, title: str, desc: str | None = None):\n        \"\"\"Create a blog post.\"\"\"\n\n    def delete(*ids: int):\n        \"\"\"Delete blog posts.\"\"\"\n\n    def list(*, between: tuple[date, date] | None = None):\n        \"\"\"View all blog posts, optionally filtering by date range.\"\"\"\n\nif __name__ == \"__main__\":\n    feud.run(Post)\n```\n\n</td>\n</tr>\n<tr>\n<td>\n<details>\n  <summary>\n    <b>Click here to view the generated help screen.</b>\n  </summary>\n<p>\n\nHelp screen for the `post` group.\n\n```console\n$ python post.py --help\n\n Usage: post.py [OPTIONS] COMMAND [ARGS]...\n\n Manage blog posts.\n\n\u256d\u2500 Options \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 --help      Show this message and exit.                            \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\u256d\u2500 Commands \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 create   Create a blog post.                                       \u2502\n\u2502 delete   Delete blog posts.                                        \u2502\n\u2502 list     View all blog posts, optionally filtering by date range.  \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\nHelp screen for the `list` command within the `post` group.\n\n```console\n$ python post.py list --help\n\n Usage: post.py list [OPTIONS]\n\n View all blog posts, optionally filtering by date range.\n\n\u256d\u2500 Options \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 --between    <DATE DATE>...                                        \u2502\n\u2502 --help                       Show this message and exit.           \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\n</p>\n</details>\n</td>\n</tr>\n<tr>\n<td>\n<details>\n  <summary>\n    <b>Click here to see usage examples.</b>\n  </summary>\n<p>\n\n- `python post.py create 1 --title \"My First Post\"`\n- `python post.py create 2 --title \"My First Detailed Post\" --desc \"Hi!\"`\n- `python post.py delete 1 2`\n- `python post.py list`\n- `python post.py list --between 2020-01-30 2021-01-30`\n\n</p>\n</details>\n</td>\n</tr>\n</table>\n\nAlternatively, if you already have some functions defined that you would like\nto run as commands, you can simply provide them to `feud.run` and it will\nautomatically generate and run a group with those commands.\n\n```python\n# post.py\n\nimport feud\nfrom datetime import date\n\ndef create_post(id: int, *, title: str, desc: str | None = None):\n    \"\"\"Create a blog post.\"\"\"\n\ndef delete_posts(*ids: int):\n    \"\"\"Delete blog posts.\"\"\"\n\ndef list_posts(*, between: tuple[date, date] | None = None):\n    \"\"\"View all blog posts, optionally filtering by date range.\"\"\"\n\nif __name__ == \"__main__\":\n    feud.run([create_post, delete_posts, list_posts])\n```\n\nYou can also use a `dict` to rename the generated commands:\n\n```python\nfeud.run({\"create\": create_post, \"delete\": delete_posts, \"list\": list_posts})\n```\n\nFor more complex applications, you can also nest commands in sub-groups:\n\n```python\nfeud.run({\"list\": list_posts, \"modify\": [create_post, delete_posts]})\n```\n\nIf commands are defined in another module, you can also\nrun the module directly and Feud will pick up all runnable objects:\n\n```python\nimport post\n\nfeud.run(post)\n```\n\nYou can even call `feud.run()` without providing any object, and it will\nautomatically discover all runnable objects in the current module.\n\n_As you can see, building a CLI using Feud does not require learning many new\nmagic methods or a domain-specific language \u2013 you can just use the simple\nPython you know and \u2764\ufe0f!_\n\n#### Registering command sub-groups\n\nGroups can be registered as sub-groups under other groups. This is a common\npattern in CLIs, allowing for interfaces packed with lots of functionality,\nbut still organized in a sensible way.\n\n<table>\n<tr>\n<td>\n\n**Example**: CLI with the following structure for running and managing a blog.\n\n- **`blog`**: Group to manage and serve a blog.\n  - `serve`: Command to run the blog HTTP server.\n  - **`post`**: Sub-group to manage blog posts.\n    - `create`: Command to create a blog post.\n    - `delete`: Command to delete blog posts.\n    - `list`: Command to view all blog posts.\n\n</td>\n</tr>\n<tr>\n<td>\n\n```python\n# blog.py\n\nimport feud\nfrom datetime import date\nfrom typing import Literal\n\nclass Blog(feud.Group):\n    \"\"\"Manage and serve a blog.\"\"\"\n\n    def serve(port: int, *, watch: bool = True, env: Literal[\"dev\", \"prod\"] = \"dev\"):\n        \"\"\"Start a local HTTP server.\"\"\"\n\nclass Post(feud.Group):\n    \"\"\"Manage blog posts.\"\"\"\n\n    def create(id: int, *, title: str, desc: str | None = None):\n        \"\"\"Create a blog post.\"\"\"\n\n    def delete(*ids: int):\n        \"\"\"Delete blog posts.\"\"\"\n\n    def list(*, between: tuple[date, date] | None = None):\n        \"\"\"View all blog posts, optionally filtering by date range.\"\"\"\n\nBlog.register(Post)\n\nif __name__ == \"__main__\":\n    feud.run(Blog)\n```\n\n</td>\n</tr>\n<tr>\n<td>\n\n<details>\n  <summary>\n    <b>Click here to view the generated help screen.</b>\n  </summary>\n<p>\n\nHelp screen for the `blog` group.\n\n```console\n$ python blog.py --help\n\n Usage: blog.py [OPTIONS] COMMAND [ARGS]...\n\n Manage and serve a blog.\n\n\u256d\u2500 Options \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 --help      Show this message and exit.                            \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\u256d\u2500 Command groups \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 post         Manage blog posts.                                    \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\u256d\u2500 Commands \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 serve        Start a local HTTP server.                            \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\nHelp screen for the `serve` command in the `blog` group.\n\n```console\n$ python blog.py serve --help\n\n Usage: blog.py serve [OPTIONS] PORT\n\n Start a local HTTP server.\n\n\u256d\u2500 Arguments \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 *  PORT    INTEGER  [required]                                     \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\u256d\u2500 Options \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 --watch/--no-watch                [default: watch]                 \u2502\n\u2502 --env                 [dev|prod]  [default: dev]                   \u2502\n\u2502 --help                            Show this message and exit.      \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\nHelp screen for the `post` sub-group in the `blog` group.\n\n```console\n$ python blog.py post --help\n\n Usage: blog.py post [OPTIONS] COMMAND [ARGS]...\n\n Manage blog posts.\n\n\u256d\u2500 Options \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 --help      Show this message and exit.                            \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\u256d\u2500 Commands \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 create   Create a blog post.                                       \u2502\n\u2502 delete   Delete blog posts.                                        \u2502\n\u2502 list     View all blog posts, optionally filtering by date range.  \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\nHelp screen for the `list` command within the `post` sub-group.\n\n```console\n$ python blog.py post list --help\n\n Usage: blog.py post list [OPTIONS]\n\n View all blog posts, optionally filtering by date range.\n\n\u256d\u2500 Options \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 --between    <DATE DATE>...                                        \u2502\n\u2502 --help                       Show this message and exit.           \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\n</p>\n</details>\n\n</td>\n</tr>\n<tr>\n<td>\n<details>\n  <summary>\n    <b>Click here to see usage examples.</b>\n  </summary>\n<p>\n\n- `python blog.py serve 8080 --no-watch --env prod`\n- `python blog.py post create 1 --title \"My First Post!\"`\n- `python blog.py post list --between 2020-01-30 2021-01-30`\n\n</p>\n</details>\n</td>\n</tr>\n</table>\n\n### Powerful typing\n\nFeud is powered by [Pydantic](https://docs.pydantic.dev/latest/) \u2013 a\nvalidation library with extensive support for many data types, including:\n\n- simple types such as integers and dates,\n- complex types such as emails, IP addresses, file/directory paths, database\n  connection strings,\n- constrained types (e.g. positive/negative integers or past/future dates).\n\n[`pydantic-extra-types`](https://github.com/pydantic/pydantic-extra-types) is\nan optional dependency offering additional types such as country names,\npayment card numbers, phone numbers, colours, latitude/longitude and more.\n\nCustom annotated types with user-defined validation functions can also be\ndefined with Pydantic.\n\n<table>\n<tr>\n<td>\n\n**Example**: Command for generating audio samples from text prompts using\na machine learning model, and storing produced audio files in an output\ndirectory.\n\n- **At least one** text prompt must be provided.\n- **No more than five** text prompts can be provided.\n- Each text prompt can have a **maximum of 12 characters**.\n- The model is specified by a path to a **file that must exist**.\n- The output directory is a path to a **folder that must exist**.\n\n</td>\n</tr>\n<tr>\n<td>\n\n```python\n# generate.py\n\nimport feud\nfrom pydantic import FilePath, DirectoryPath, conlist, constr\n\ndef generate(\n    prompts: conlist(constr(max_length=12), min_length=1, max_length=5),\n    *,\n    model: FilePath,\n    output: DirectoryPath,\n):\n    \"\"\"Generates audio from prompts using a trained model.\"\"\"\n\nif __name__ == \"__main__\":\n    feud.run(generate)\n```\n\n</td>\n</tr>\n<tr>\n<td>\n<details>\n  <summary>\n    <b>Click here to view the generated help screen.</b>\n  </summary>\n<p>\n\nHelp screen for the `generate` command.\n\n```console\n$ python generate.py --help\n\n Usage: generate.py [OPTIONS] [PROMPTS]...\n\n Generates audio from prompts using a trained model.\n\n\u256d\u2500 Arguments \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 PROMPTS    TEXT                                                    \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\u256d\u2500 Options \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 *  --model     FILE       [required]                               \u2502\n\u2502 *  --output    DIRECTORY  [required]                               \u2502\n\u2502    --help                 Show this message and exit.              \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\n</p>\n</details>\n</td>\n</tr>\n<tr>\n<td>\n<details>\n  <summary>\n    <b>Click here to see usage examples.</b>\n  </summary>\n<p>\n\nIf we run the script without prompts, we get an error that at least one prompt\nmust be provided.\n\n```console\n$ python generate.py --model models/real_model.pt --output audio/\n\n Usage: generate.py [OPTIONS] [PROMPTS]...\n\n Try 'generate.py --help' for help\n\u256d\u2500 Error \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 1 validation error for command 'generate'                                    \u2502\n\u2502 [PROMPTS]...                                                                 \u2502\n\u2502   List should have at least 1 item after validation, not 0 [input_value=()]  \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\nIf we provide a prompt longer than 12 characters, we also get an error.\n\n```console\n$ python generate.py \"dog barking\" \"cat meowing\" \"fish blubbing\" --model models/real_model.pt --output audio/\n\n Usage: generate.py [OPTIONS] [PROMPTS]...\n\n Try 'generate.py --help' for help\n\u256d\u2500 Error \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 1 validation error for command 'generate'                                    \u2502\n\u2502 [PROMPTS]... [2]                                                             \u2502\n\u2502   String should have at most 12 characters [input_value='fish blubbing']     \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\n`FilePath` indicates that the file must already exist, so we get an error if we\nprovide a non-existent file.\n\n```console\n$ python generate.py \"dog barking\" \"cat meowing\" --model models/fake_model.pt\n\n Usage: generate.py [OPTIONS] [PROMPTS]...\n\n Try 'generate.py --help' for help\n\u256d\u2500 Error \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 Invalid value for '--model': File 'models/fake_model.pt' does not exist.     \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\n`DirectoryPath` indicates that the path must be a directory, so we\nget an error if we provide a file.\n\n```console\n$ python generate.py \"dog barking\" \"cat meowing\" --output audio.txt\n\n Usage: generate.py [OPTIONS] [PROMPTS]...\n\n Try 'generate.py --help' for help\n\u256d\u2500 Error \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 Invalid value for '--output': Directory 'audio.txt' is a file.               \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\n</p>\n</details>\n</td>\n</tr>\n</table>\n\n_By relying on Pydantic to handle the hard work of validation, we can contain all\nof the required CLI constraints in a simple function signature, leaving you to focus\non the important part \u2013 implementing your commands._\n\n### Highly configurable and extensible\n\nWhile designed to be simpler than Click, this comes with the trade-off that\nFeud is also more opinionated than Click and only directly implements a subset\nof its functionality.\n\nHowever, Feud was designed to allow for Click to seamlessly slot in whenever\nmanual overrides are necessary.\n\n<table>\n<tr>\n<td>\n\n**Example**: Use [`click.password_option`](https://click.palletsprojects.com/en/8.1.x/api/#click.password_option)\nto securely prompt the user for a password, but still validate based on the\ntype hint (length should be \u2265 10 characters).\n\n</td>\n</tr>\n<tr>\n<td>\n\n```python\n# login.py\n\nimport feud\nfrom feud import click\nfrom pydantic import constr\n\n@click.password_option(\"--password\", help=\"The user's password (\u2265 10 characters).\")\ndef login(*, username: str, password: constr(min_length=10)):\n    \"\"\"Log in as a user.\n\n    Parameters\n    ----------\n    username:\n        The user's username.\n    \"\"\"\n\nif __name__ == \"__main__\":\n    feud.run(login)\n```\n\n</td>\n</tr>\n<tr>\n<td>\n<details>\n  <summary>\n    <b>Click here to view the generated help screen.</b>\n  </summary>\n<p>\n\nHelp screen for the `login` command.\n\n```console\n$ python login.py --help\n\n Usage: login.py [OPTIONS]\n\n Log in as a user.\n\n\u256d\u2500 Options \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 *  --username    TEXT  The user's username. [required]             \u2502\n\u2502    --password    TEXT  The user's password (\u2265 10 characters).      \u2502\n\u2502    --help              Show this message and exit.                 \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\n</p>\n</details>\n</td>\n</tr>\n<tr>\n<td>\n<details>\n  <summary>\n    <b>Click here to see usage examples.</b>\n  </summary>\n<p>\n\n```console\n$ python login.py --username alice\n\nPassword: ***\nRepeat for confirmation: ***\n\n Usage: login.py [OPTIONS]\n\n Try 'login.py --help' for help\n\u256d\u2500 Error \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 1 validation error for command 'login'                             \u2502\n\u2502 --password                                                         \u2502\n\u2502   String should have at least 10 characters [input_value=hidden]   \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\n</p>\n</detail>\n</td>\n</tr>\n</table>\n\n## Installation\n\nYou can install Feud using `pip`.\n\nThe latest stable version of Feud can be installed with the following command.\n\n```console\npip install \"feud[all]\"\n```\n\nThis installs Feud with the optional dependencies:\n\n- [`rich-click`](https://github.com/ewels/rich-click) (can install individually with `pip install \"feud[rich]\"`)<br/>\n  _Provides improved formatting for CLIs produced by Feud._\n- [`pydantic-extra-types`](https://github.com/pydantic/pydantic-extra-types) (can install individually with `pip install \"feud[extra-types]\"`)<br/>\n  _Provides additional types that can be used as type hints for Feud commands._\n- [`email-validator`](https://github.com/JoshData/python-email-validator) (can install individually with `pip install \"feud[email]\"`)<br/>\n  _Provides Pydantic support for email validation._\n\nTo install Feud without any optional dependencies, simply run `pip install feud`.\n\n> [!CAUTION]\n> Feud **will break** if used with postponed type hint evaluation ([PEP563](https://peps.python.org/pep-0563/)), i.e.:\n>\n> ```python\n> from __future__ import annotations\n> ```\n>\n> This is because Feud relies on type hint evaluation in order to determine the expected input type for command parameters.\n\n### Improved formatting with Rich\n\nBelow is a comparison of Feud with and without `rich-click`.\n\n<table>\n<tr>\n<th>\nWith Rich-formatted output\n</th>\n<th>\nWithout Rich-formatted output\n</th>\n</tr>\n<tr>\n<td>\n<img src=\"/docs/source/_static/images/readme/help-rich.png\"/>\n</td>\n<td>\n<img src=\"/docs/source/_static/images/readme/help-no-rich.png\"/>\n</td>\n</tr>\n<tr>\n<td>\n<img src=\"/docs/source/_static/images/readme/error-rich.png\"/>\n</td>\n<td>\n<img src=\"/docs/source/_static/images/readme/error-no-rich.png\"/>\n</td>\n</tr>\n</table>\n\n## Build status\n\n| `master`                                                                                                                                                                                       | `dev`                                                                                                                                                                                            |\n| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| [![CircleCI Build (Master)](https://img.shields.io/circleci/build/github/eonu/feud/master?logo=circleci&style=flat-square)](https://app.circleci.com/pipelines/github/eonu/feud?branch=master) | [![CircleCI Build (Development)](https://img.shields.io/circleci/build/github/eonu/feud/dev?logo=circleci&style=flat-square)](https://app.circleci.com/pipelines/github/eonu/feud?branch=master) |\n\n## Documentation\n\n- [API reference](https://docs.feud.wiki):\n  Library documentation for public modules, classes and functions.\n\n<!--\n- [Official website](https://feud.wiki):\n  High level information about the package.\n- [User guide](https://feud.wiki/guide):\n  Detailed walkthrough of features, with examples of both simple and complex\n  usage patterns.\n-->\n\n## Related projects\n\nFeud either relies heavily on, or was inspired by the following\npackages. It would be greatly appreciated if you also supported the below\nmaintainers and the work they have done that Feud has built upon.\n\n<table>\n\n<tr>\n  <th>Project</th>\n  <th>Description</th>\n</tr>\n<tr>\n<td>\n\n[**Click**](https://github.com/pallets/click)\n\n<sup>\n\nby&nbsp;[@pallets](https://github.com/pallets)\n\n</sup>\n  \n</td>\n<td>\n\nFeud is essentially a wrapper around Click that takes classes and functions\nwith type hints and intelligently 'compiles' them into a ready-to-use Click\ngenerated CLI.\n\n</td>\n</tr>\n<tr>\n<td>\n\n[**Rich Click**](https://github.com/ewels/rich-click)\n\n<sup>\n\nby&nbsp;[@ewels](https://github.com/ewels)\n\n</sup>\n\n</td>\n<td>\n\nA shim around Click that renders help output nicely using\n[Rich](https://github.com/Textualize/rich).\n\n</td>\n</tr>\n<tr>\n<td>\n\n[**Pydantic**](https://github.com/pydantic/pydantic)\n\n<sup>\n\nby&nbsp;[@samuelcolvin](https://github.com/samuelcolvin)\n\n</sup>\n\n</td>\n<td>\n\nPydantic is a validation package that makes it easy to declaratively validate\ninput data based on type hints.\n\nThe package offers support for common standard library types, plus more complex\ntypes which can also be used as type hints in Feud commands for input validation.\n\n</td>\n</tr>\n<tr>\n<td>\n\n[**Typer**](https://github.com/tiangolo/typer)\n\n<sup>\n\nby&nbsp;[@tiangolo](https://github.com/tiangolo)\n\n</sup>\n\n</td>\n<td>\n\nTyper shares a similar ideology to Feud, in that building CLIs should be\nsimple and not require learning new functions or constantly referring to\nlibrary documentation. Typer is also based on Click.\n\nTyper is a more complete library for building CLIs overall, but currently\nlacks support for more complex types such as those offered by Pydantic.\n\n</td>\n</tr>\n<tr>\n<td>\n\n[**Thor**](https://github.com/rails/thor)\n\n<sup>\n\nby&nbsp;[@rails](https://github.com/rails)\n\n</sup>\n\n</td>\n<td>\n\nThough not a Python package, the highly object-oriented design of Thor (a CLI\nbuilding package in Ruby) \u2013 in particular the use of classes to define command\ngroups \u2013 greatly influenced the implementation of the `feud.Group` class.\n\n</td>\n</tr>\n\n</table>\n\n## Contributing\n\nAll contributions to this repository are greatly appreciated. Contribution guidelines can be found [here](/CONTRIBUTING.md).\n\n> <img src=\"https://i.postimg.cc/jq3MZSTD/avatar.png\" align=\"left\"/>\n> <b>We're living in an imperfect world!</b><br/>\n> <sup>Feud is in a public beta-test phase, likely with <em>lots</em> of bugs. Please <a href=\"https://github.com/eonu/feud/issues/new/choose\">leave feedback</a> if you come across anything strange!</sup>\n\n## Licensing\n\nFeud is released under the [MIT](https://opensource.org/licenses/MIT) license.\n\n---\n\n<p align=\"center\">\n  <b>Feud</b> &copy; 2023-2025, Edwin Onuonga - Released under the <a href=\"https://opensource.org/licenses/MIT\">MIT</a> license.<br/>\n  <em>Authored and maintained by Edwin Onuonga.</em>\n</p>\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Build powerful CLIs with simple idiomatic Python, driven by type hints. Not all arguments are bad.",
    "version": "0.3.2",
    "project_urls": {
        "Documentation": "https://docs.feud.wiki",
        "Homepage": "https://github.com/eonu/feud",
        "Repository": "https://github.com/eonu/feud"
    },
    "split_keywords": [
        "python",
        " cli",
        " terminal",
        " command-line",
        " typed",
        " docstrings",
        " typehints",
        " pydantic",
        " click"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d20691b597f9f752ef9c926da6da4be47e66a653193426192b0877f4869402c2",
                "md5": "7e510a3915a8c8452bd98e62b305d437",
                "sha256": "6ea6b8cd475aebe74f35f40a3ed4e3f413d10af0020aaa9fae83745f8f46e6e6"
            },
            "downloads": -1,
            "filename": "feud-0.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7e510a3915a8c8452bd98e62b305d437",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 62967,
            "upload_time": "2024-04-01T19:02:36",
            "upload_time_iso_8601": "2024-04-01T19:02:36.644098Z",
            "url": "https://files.pythonhosted.org/packages/d2/06/91b597f9f752ef9c926da6da4be47e66a653193426192b0877f4869402c2/feud-0.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "747855b9704bf5022caa4e3eeb0f8efe0c2e5e43d4f082e1ddba4122a4e45d80",
                "md5": "0789981f1acfc9822cb572633c1e7e30",
                "sha256": "2a7a4c6a32454ad0d859d808bd6593d61bc50aef652201bd4f228100233026ad"
            },
            "downloads": -1,
            "filename": "feud-0.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "0789981f1acfc9822cb572633c1e7e30",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 63458,
            "upload_time": "2024-04-01T19:02:38",
            "upload_time_iso_8601": "2024-04-01T19:02:38.496278Z",
            "url": "https://files.pythonhosted.org/packages/74/78/55b9704bf5022caa4e3eeb0f8efe0c2e5e43d4f082e1ddba4122a4e45d80/feud-0.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-01 19:02:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "eonu",
    "github_project": "feud",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "circle": true,
    "tox": true,
    "lcname": "feud"
}
        
Elapsed time: 0.20862s