Metadata-Version: 2.1
Name: argparse-tui
Version: 0.2.0
Summary: Display your Python argparse parser as a TUI.
Author-email: Donald Mellenbruch <hello@f2dv.com>
License: Copyright 2023 Donald Mellenbruch
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
        
Project-URL: Homepage, https://www.f2dv.com/r/argparse-tui
Project-URL: Repository, https://www.github.com/fresh2dev/argparse-tui
Project-URL: Funding, https://www.f2dv.com/fund
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: textual (>=0.26.0)
Requires-Dist: typing-extensions ; python_version < "3.10"
Provides-Extra: dev
Requires-Dist: python-lsp-server[rope] (==1.*) ; extra == 'dev'
Requires-Dist: pylint (==2.*) ; extra == 'dev'
Requires-Dist: pylint-pytest (==1.*) ; extra == 'dev'
Requires-Dist: mypy[reports] (==1.*) ; extra == 'dev'
Requires-Dist: ruff (==0.*) ; extra == 'dev'
Requires-Dist: black[jupyter] (==23.*) ; extra == 'dev'
Requires-Dist: isort (==5.*) ; extra == 'dev'
Requires-Dist: bump2version (==1.*) ; extra == 'dev'
Requires-Dist: pdbpp ; extra == 'dev'
Requires-Dist: ipykernel ; extra == 'dev'
Requires-Dist: ipywidgets ; extra == 'dev'
Requires-Dist: ipython ; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs (==1.*) ; extra == 'docs'
Requires-Dist: mkdocs-material (==9.*) ; extra == 'docs'
Requires-Dist: mkdocs-jupyter (==0.24.*) ; extra == 'docs'
Requires-Dist: mkdocstrings[python] (==0.20.*) ; extra == 'docs'
Requires-Dist: mkdocs-autorefs (==0.*) ; extra == 'docs'
Requires-Dist: mkdocs-include-dir-to-nav (==1.*) ; extra == 'docs'
Provides-Extra: tests
Requires-Dist: pytest (==7.*) ; extra == 'tests'
Requires-Dist: pytest-cov (==4.*) ; extra == 'tests'
Requires-Dist: pytest-html (==3.*) ; extra == 'tests'
Requires-Dist: pytest-sugar (==0.*) ; extra == 'tests'
Requires-Dist: pytest-custom-exit-code (==0.3.*) ; extra == 'tests'
Requires-Dist: pylint (==2.*) ; extra == 'tests'
Requires-Dist: pylint-pytest (==1.*) ; extra == 'tests'
Requires-Dist: packaging (==23.*) ; extra == 'tests'
Requires-Dist: mockish (<2,>=0.1.1) ; extra == 'tests'

# argparse-tui

> Display your Python argparse parser as a TUI.

| Links         |                                               |
|---------------|-----------------------------------------------|
| Code Repo     | https://www.github.com/fresh2dev/argparse-tui |
| Mirror Repo   | https://www.f2dv.com/r/argparse-tui           |
| Documentation | https://www.f2dv.com/r/argparse-tui           |
| Changelog     | https://www.f2dv.com/r/argparse-tui/changelog |
| License       | https://www.f2dv.com/r/argparse-tui/license   |
| Funding       | https://www.f2dv.com/fund                     |

[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/fresh2dev/argparse-tui?color=blue&style=for-the-badge)](https://www.f2dv.com/r/argparse-tui/changelog)
[![GitHub Release Date](https://img.shields.io/github/release-date/fresh2dev/argparse-tui?color=blue&style=for-the-badge)](https://www.f2dv.com/r/argparse-tui/changelog)
[![License](https://img.shields.io/github/license/fresh2dev/argparse-tui?color=blue&style=for-the-badge)](https://www.f2dv.com/r/argparse-tui/license)
[![GitHub Repo stars](https://img.shields.io/github/stars/fresh2dev/argparse-tui?color=blue&style=for-the-badge)](https://star-history.com/#fresh2dev/argparse-tui&Date)
[![GitHub issues](https://img.shields.io/github/issues-raw/fresh2dev/argparse-tui?color=blue&style=for-the-badge)](https://www.github.com/fresh2dev/argparse-tui/issues)
[![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/fresh2dev/argparse-tui?color=blue&style=for-the-badge)](https://www.github.com/fresh2dev/argparse-tui/pulls)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/argparse-tui?color=blue&style=for-the-badge)](https://pypi.org/project/argparse-tui)
[![Docker Pulls](https://img.shields.io/docker/pulls/fresh2dev/argparse-tui?color=blue&style=for-the-badge)](https://hub.docker.com/r/fresh2dev/argparse-tui)
[![Changelog](https://img.shields.io/website?down_message=unavailable&label=docs&style=for-the-badge&up_color=blue&up_message=available&url=https://www.f2dv.com/r/argparse-tui/changelog)](https://www.f2dv.com/r/argparse-tui/changelog)
[![Funding](https://img.shields.io/badge/funding-%24%24%24-blue?style=for-the-badge)](https://www.f2dv.com/fund)

---

## Overview

This is a fork of the Textualize [Trogon TUI library](https://github.com/Textualize/trogon.git) that introduces these features:

- add support for Python's argparse parsers
    - add `--tui` flag as an argument
    - or, add `tui` command to your subparser
    - or, invoke the TUI with `invoke_tui(parser)`
- remove support for Click
- add ability for TUI parameter to filter subcommands
- support for manually constructing schemas
- support for argparse
- add examples for yapx, myke, and sys.argv
- support ommission of hidden parameters and subcommands from the TUI
- support the redaction of sensitive "secret" values
- support for showing required prompts as read-only
- ability to join list arguments values like this: `-x 1 -x 2 -x 3` (default), or like this: `-x 1 2 3`
- vim-friendly keybindings

## Install

Install from PyPI:

```
pip install argparse-tui
```

## Use

```python
import arparse
from argparse_tui import add_tui_argument, add_tui_command

parser = argparse.ArgumentParser()

# Add tui argument (my-cli --tui)
add_tui_argument(parser, option_strings=["--tui"], help="Open Textual UI")

# Or, add tui command (my-cli tui)
add_tui_command(parser, command="tui", help="Open Textual UI")

parser.print_help()
```

### `invoke_tui`

argparse-tui offers this function to display a TUI based on the arguments of the given parser:

```python
import argparse

from argparse_tui import invoke_tui

parser = argparse.ArgumentParser(prog="echo")

parser.add_argument("STRING", nargs="*")

parser.add_argument(
    "-n",
    action="store_true",
    help="do not output the trailing newline",
)

invoke_tui(parser)
```

In this way, `argparse` is not actually serving as an argument parser, but instead as the specification language for the TUI. Whoa.

### ChatGPT and TUIview

Given the structured help text output of some CLI program, it turns out ChatGPT is decent at implementing an equivalent CLI using a Python argparse parser. Whoaaa.

Coupled with `invoke_tui`, this means that argparse-tui is capable of producing a TUI for any CLI. This is the idea behind a tool built using argparse-tui: [TUIview](https://github.com/fresh2dev/tuiview). It does not use ChatGPT itself, but I used ChatGPT to generate equivalent-enough argparse parsers for `git`, `rsync`, `grep`.

## Docs

See more examples in the [reference docs](https://www.f2dv.com/r/argparse-tui/reference).


## Support

*Brought to you by...*

<a href="https://www.f2dv.com"><img src="https://img.fresh2.dev/fresh2dev.svg" style="filter: invert(50%);"></img></a>
