recline


Namerecline JSON
Version 2023.5 PyPI version JSON
download
home_pagehttps://github.com/NetApp/recline
SummaryWriting argparse-based command line applications can become tedious, repetitive, and difficult to do right. Relax and let this library free you from that burden.
upload_time2023-05-23 11:24:06
maintainer
docs_urlNone
authorNetApp
requires_python>=3.7.2,<4
licenseBSD-3-Clause
keywords cli interactive shell argparse recline
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            ![](https://github.com/NetApp/recline/workflows/build/badge.svg?branch=main)
[![Gitter](https://badges.gitter.im/netapp-recline/community.svg)](https://gitter.im/netapp-recline/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

# recline

Writing argparse-based command line applications can become tedious, repetitive,
and difficult to do right. Relax and let this library free you from that burden.

This library helps you quickly implement an interactive command-based application in Python.

## Documentation First
We all know that writing documentation is very important and yet it can easily become
and afterthought or a nice to have if we're not diligent. This is often because it
means duplicating a piece of your implementation in words, effectively writing the
same thing twice. Recline strives to deduplicate this work by taking a documentation
first attitude where your documentation _becomes_ the implementation without additional
work from you.

## Interactive

The default mode is to run a REPL interface where a prompt is given to the user, the
user types one of the available commands, the application processes it, displays the
result, and then control is returned to the user once more.

But if your user isn't expected to or doesn't always want to run multiple commands,
you also get a more traditional command-line interface for free.

## Command-based

The application will be command based. Each command will have one or more words
that identify the command. It may also have one or more arguments that augment or
vary the action that command will take.

## Batteries included

While the library is designed to be easy to implement for simple or small applications,
it also comes with full power features for larger use cases including:

* Tab completion
* Input verification
* Output formatting
* Debugger integration

# Before getting started

Some things to consider and prepare before you can use this library.

## Software requirements

```
1. Python 3.5 or later
```

## Installing and importing the library

You can install the package [from pypi](https://pypi.org/project/recline) using the pip utility:

```
pip install recline
```

You can then import the library into your application:

```python
import recline
```

# Quick Start

After installing the package, you can get started with a few lines in `hello.py`:

```python
import recline

@recline.command
def hello(name: str = None) -> None:
    """A basic hello world

    You can greet just about anybody with this command if they give you their name!

    Args:
        name: If a name is provided, the greeting will be more personal
    """
    response = "I'm at your command"
    if name:
        response += ", %s" % name
    print(response)

recline.relax()
```

## Interactive mode

The default mode when a recline applciation is run is an interactive style. Running
our above `hello.py` results in the following output:

```
$ python hello.py
> help
Available Commands:

hello - A basic hello world You can greet just about anybody with this command if

Built-in Commands
-----------------
exit - Exit the application
help - Display a list of available commands and their short description
man - Display the full man page for a given command
> hello ?
A basic hello world You can greet just about anybody with this command if

Optional arguments:
  -name <name> If a name is provided, the greeting will be more personal
    Default: None
> hello
I'm at your command
> hello -name Dave
I'm at your command, Dave
> exit
$
```

## Non-interactive mode

If you would like to use the application as part of a larger script, it is much
easier to do in a non-interactive way. This is also possible using recline without
needing to change the application. Here's an example:

```
$ python hello.py -c "hello -name Dave"
I'm at your command, Dave
$
```

See the [full documentation](https://netapp.github.io/recline) for more advanced usages and examples

# Contributing [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/NetApp/recline/issues)

You may read about the contribution process including how to build and test your changes [here](CONTRIBUTING.md).

# Why recline?

There are a large number of different command line libraries on PyPi and GitHub.
And some of them have the same sort of decorator design. Most, however, are missing
the interactive elements that recline focuses on (tab completion, command chaining,
background jobs, man pages). If you're still looking for the right fit for your
application and recline isn't it, you can check out these other fine projects (in no
particular order):

* https://github.com/kootenpv/cliche
* https://github.com/gowithfloat/clippy
* https://github.com/epsy/clize
* https://github.com/pallets/click
* https://github.com/micheles/plac
* https://github.com/google/python-fire
* https://github.com/kennethreitz-archive/clint
* https://docs.openstack.org/cliff/latest
* https://github.com/miguelgrinberg/climax


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/NetApp/recline",
    "name": "recline",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7.2,<4",
    "maintainer_email": "",
    "keywords": "cli,interactive,shell,argparse,recline",
    "author": "NetApp",
    "author_email": "ng-netapp-oss@netapp.com",
    "download_url": "https://files.pythonhosted.org/packages/dc/a0/f67765ed42d7f6074e5ee4d010d5582784bef5079f59fdc806d0c167128b/recline-2023.5.tar.gz",
    "platform": null,
    "description": "![](https://github.com/NetApp/recline/workflows/build/badge.svg?branch=main)\n[![Gitter](https://badges.gitter.im/netapp-recline/community.svg)](https://gitter.im/netapp-recline/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)\n\n# recline\n\nWriting argparse-based command line applications can become tedious, repetitive,\nand difficult to do right. Relax and let this library free you from that burden.\n\nThis library helps you quickly implement an interactive command-based application in Python.\n\n## Documentation First\nWe all know that writing documentation is very important and yet it can easily become\nand afterthought or a nice to have if we're not diligent. This is often because it\nmeans duplicating a piece of your implementation in words, effectively writing the\nsame thing twice. Recline strives to deduplicate this work by taking a documentation\nfirst attitude where your documentation _becomes_ the implementation without additional\nwork from you.\n\n## Interactive\n\nThe default mode is to run a REPL interface where a prompt is given to the user, the\nuser types one of the available commands, the application processes it, displays the\nresult, and then control is returned to the user once more.\n\nBut if your user isn't expected to or doesn't always want to run multiple commands,\nyou also get a more traditional command-line interface for free.\n\n## Command-based\n\nThe application will be command based. Each command will have one or more words\nthat identify the command. It may also have one or more arguments that augment or\nvary the action that command will take.\n\n## Batteries included\n\nWhile the library is designed to be easy to implement for simple or small applications,\nit also comes with full power features for larger use cases including:\n\n* Tab completion\n* Input verification\n* Output formatting\n* Debugger integration\n\n# Before getting started\n\nSome things to consider and prepare before you can use this library.\n\n## Software requirements\n\n```\n1. Python 3.5 or later\n```\n\n## Installing and importing the library\n\nYou can install the package [from pypi](https://pypi.org/project/recline) using the pip utility:\n\n```\npip install recline\n```\n\nYou can then import the library into your application:\n\n```python\nimport recline\n```\n\n# Quick Start\n\nAfter installing the package, you can get started with a few lines in `hello.py`:\n\n```python\nimport recline\n\n@recline.command\ndef hello(name: str = None) -> None:\n    \"\"\"A basic hello world\n\n    You can greet just about anybody with this command if they give you their name!\n\n    Args:\n        name: If a name is provided, the greeting will be more personal\n    \"\"\"\n    response = \"I'm at your command\"\n    if name:\n        response += \", %s\" % name\n    print(response)\n\nrecline.relax()\n```\n\n## Interactive mode\n\nThe default mode when a recline applciation is run is an interactive style. Running\nour above `hello.py` results in the following output:\n\n```\n$ python hello.py\n> help\nAvailable Commands:\n\nhello - A basic hello world You can greet just about anybody with this command if\n\nBuilt-in Commands\n-----------------\nexit - Exit the application\nhelp - Display a list of available commands and their short description\nman - Display the full man page for a given command\n> hello ?\nA basic hello world You can greet just about anybody with this command if\n\nOptional arguments:\n  -name <name> If a name is provided, the greeting will be more personal\n    Default: None\n> hello\nI'm at your command\n> hello -name Dave\nI'm at your command, Dave\n> exit\n$\n```\n\n## Non-interactive mode\n\nIf you would like to use the application as part of a larger script, it is much\neasier to do in a non-interactive way. This is also possible using recline without\nneeding to change the application. Here's an example:\n\n```\n$ python hello.py -c \"hello -name Dave\"\nI'm at your command, Dave\n$\n```\n\nSee the [full documentation](https://netapp.github.io/recline) for more advanced usages and examples\n\n# Contributing [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/NetApp/recline/issues)\n\nYou may read about the contribution process including how to build and test your changes [here](CONTRIBUTING.md).\n\n# Why recline?\n\nThere are a large number of different command line libraries on PyPi and GitHub.\nAnd some of them have the same sort of decorator design. Most, however, are missing\nthe interactive elements that recline focuses on (tab completion, command chaining,\nbackground jobs, man pages). If you're still looking for the right fit for your\napplication and recline isn't it, you can check out these other fine projects (in no\nparticular order):\n\n* https://github.com/kootenpv/cliche\n* https://github.com/gowithfloat/clippy\n* https://github.com/epsy/clize\n* https://github.com/pallets/click\n* https://github.com/micheles/plac\n* https://github.com/google/python-fire\n* https://github.com/kennethreitz-archive/clint\n* https://docs.openstack.org/cliff/latest\n* https://github.com/miguelgrinberg/climax\n\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Writing argparse-based command line applications can become tedious, repetitive, and difficult to do right. Relax and let this library free you from that burden.",
    "version": "2023.5",
    "project_urls": {
        "Documentation": "https://netapp.github.io/recline",
        "Homepage": "https://github.com/NetApp/recline",
        "Repository": "https://github.com/NetApp/recline"
    },
    "split_keywords": [
        "cli",
        "interactive",
        "shell",
        "argparse",
        "recline"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b6c3c3db747171b293bbc9c1eaf943f28fa0770254f942d84747bc44f2f1ae19",
                "md5": "bae0a2156a31a4db9181582d7840f090",
                "sha256": "88412f75d387a4554d6564c6f91eeb4719d041dbe8e74c32f5c91ca43e3d0a94"
            },
            "downloads": -1,
            "filename": "recline-2023.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bae0a2156a31a4db9181582d7840f090",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7.2,<4",
            "size": 62665,
            "upload_time": "2023-05-23T11:24:05",
            "upload_time_iso_8601": "2023-05-23T11:24:05.471315Z",
            "url": "https://files.pythonhosted.org/packages/b6/c3/c3db747171b293bbc9c1eaf943f28fa0770254f942d84747bc44f2f1ae19/recline-2023.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dca0f67765ed42d7f6074e5ee4d010d5582784bef5079f59fdc806d0c167128b",
                "md5": "d1d03854d665f635b4558b1648d8678b",
                "sha256": "cbf9d50ab0ec9a32d16d7b1cd2fccb273250ba2d164f22413de57f6ddea4f666"
            },
            "downloads": -1,
            "filename": "recline-2023.5.tar.gz",
            "has_sig": false,
            "md5_digest": "d1d03854d665f635b4558b1648d8678b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7.2,<4",
            "size": 58802,
            "upload_time": "2023-05-23T11:24:06",
            "upload_time_iso_8601": "2023-05-23T11:24:06.989741Z",
            "url": "https://files.pythonhosted.org/packages/dc/a0/f67765ed42d7f6074e5ee4d010d5582784bef5079f59fdc806d0c167128b/recline-2023.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-23 11:24:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NetApp",
    "github_project": "recline",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "recline"
}
        
Elapsed time: 0.16616s