Skip to content

Commit 5bbec25

Browse files
committed
Merge branch 'dev'
2 parents 6a59be9 + 227502b commit 5bbec25

19 files changed

+1653
-194
lines changed

.copier-answers.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 78c3b92
2+
_commit: 8af3bf2
33
_src_path: ../../templates/copier-f2dv-project
44
author_email: hello@f2dv.com
55
author_name: Donald Mellenbruch
@@ -12,9 +12,9 @@ is_minimal: false
1212
is_python: true
1313
license_type: MIT
1414
package_name: argparse_tui
15-
project_description: Your Argparse CLI, now with a TUI.
15+
project_description: Present your Argparse CLI as a Textual UI (TUI).
1616
project_name: argparse-tui
17-
python_version: '3.8'
17+
python_version: '3.9'
1818
repo_name: fresh2dev/argparse-tui
1919
repo_owner: fresh2dev
2020
repo_url: https://www.github.com/fresh2dev/argparse-tui

.envrc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
# Configure Python development environment.
2-
export UV_PYTHON_PREFERENCE="only-managed" UV_PYTHON="3.8"
3-
[ -d ".venv" ] || uv venv
4-
[ ! -f "requirements.txt" ] || uv pip install -r requirements.txt
5-
[ ! -f "pyproject.toml" ] || uv pip install --all-extras -r pyproject.toml --editable .
1+
uv sync --python='3.9' --all-extras
62
. ./.venv/bin/activate

.gitea/workflows/build-deploy-image.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ jobs:
6767
# matrix: ${{ fromJson(needs.find-dockerfiles.outputs.matrix) }}
6868
matrix:
6969
include:
70-
# - dockerfile: Dockerfile
71-
# image_suffix: ""
72-
- dockerfile: Dockerfile-docs
73-
image_suffix: "-docs"
70+
- dockerfile: Dockerfile
71+
image_suffix: ""
72+
# - dockerfile: Dockerfile-docs
73+
# image_suffix: "-docs"
7474
fail-fast: true
7575
steps:
7676
### Checkout

.gitea/workflows/build-publish-python-package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
runs-on: 'ubuntu-latest'
2222
strategy:
2323
matrix:
24-
python-version: ['3.9', '3.10', '3.11', '3.12']
24+
python-version: ['3.10', '3.11', '3.12', '3.13']
2525
max-parallel: 3
2626
fail-fast: true
2727
steps:

CHANGELOG.md

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## 0.3.0 - 2024-11-07
6+
7+
**Full Changelog**: https://github.com/fresh2dev/argparse-tui/compare/0.2.6...0.3.0
8+
9+
### :clap: Features
10+
11+
- Add ability to open TUI with focus on a nested subcommand
12+
13+
### :point_right: Changes
14+
15+
- *Breaking* - Require python >= 3.9
16+
517
## 0.2.6 - 2024-10-23
618

719
> This release cherry-picks several upstream fixes introduced in [Trogon v0.6.0](https://github.com/Textualize/trogon/releases/tag/v0.6.0)
@@ -10,7 +22,7 @@ All notable changes to this project will be documented in this file.
1022

1123
### :fist: Fixes
1224

13-
- Fixing typing issues, ensure *args and **kwargs are passed to App superclass to help compatibility. Use `get_default_screen` instead of pushing a screen on_mount.
25+
- Fixing typing issues, ensure \*args and \*\*kwargs are passed to App superclass to help compatibility. Use `get_default_screen` instead of pushing a screen on_mount.
1426
- Fix crashes on modern Textual, involving minor refactors
1527
- Do not treat Select.BLANK as a supplied value
1628

@@ -54,94 +66,94 @@ All notable changes to this project will be documented in this file.
5466

5567
### :fist: Fixes
5668

57-
- Type lookup when given a partial with kwargs [8c48e8c]
58-
- Enforce proper handling of is_flag arguments [450cc5e]
69+
- Type lookup when given a partial with kwargs \[8c48e8c\]
70+
- Enforce proper handling of is_flag arguments \[450cc5e\]
5971

6072
### :point_right: Changes
6173

62-
- Use more generic type-hints [016d634]
63-
- Pin textual < 1 [f17b432]
74+
- Use more generic type-hints \[016d634\]
75+
- Pin textual \< 1 \[f17b432\]
6476

6577
## 0.2.1 - 2023-08-24
6678

6779
### :point_right: Changes
6880

69-
- Derive root cmd name from parser.prog [52d6a65]
70-
- Remove 'group' label [45dc5d4]
81+
- Derive root cmd name from parser.prog \[52d6a65\]
82+
- Remove 'group' label \[45dc5d4\]
7183

7284
### :fist: Fixes
7385

74-
- Correct logic for required arguments [7e818a6]
86+
- Correct logic for required arguments \[7e818a6\]
7587

7688
## 0.2.0 - 2023-07-29
7789

7890
### :clap: Features
7991

80-
- Passthru command-line values to TUI form [4ed259f]
92+
- Passthru command-line values to TUI form \[4ed259f\]
8193

8294
### :point_right: Changes
8395

84-
- *Breaking:* Remove support for mandatory prompts [76beab4]
96+
- *Breaking:* Remove support for mandatory prompts \[76beab4\]
8597

86-
---
98+
______________________________________________________________________
8799

88100
## 0.1.3 - 2023-07-28
89101

90102
### :clap: Features
91103

92-
- Copy command to clipboard before running [1d03f57]
104+
- Copy command to clipboard before running \[1d03f57\]
93105

94106
### :point_right: Changes
95107

96-
- `add_command` will now return the subparser [5fe982d]
97-
- Suppress error if clipboard copy fails [6e00995]
98-
- Rename example [bd245fe]
108+
- `add_command` will now return the subparser \[5fe982d\]
109+
- Suppress error if clipboard copy fails \[6e00995\]
110+
- Rename example \[bd245fe\]
99111

100-
---
112+
______________________________________________________________________
101113

102114
## 0.1.2 - 2023-07-24
103115

104116
### :clap: Features
105117

106-
- `invoke_tui` [554827b]
118+
- `invoke_tui` \[554827b\]
107119

108120
### :fist: Fixes
109121

110-
- Handle argparse.REMAINDER [5447b92]
111-
- Positional arguments go after options in the generated command [0a91a2e]
122+
- Handle argparse.REMAINDER \[5447b92\]
123+
- Positional arguments go after options in the generated command \[0a91a2e\]
112124

113-
---
125+
______________________________________________________________________
114126

115127
## 0.1.1 - 2023-07-23
116128

117129
### :fist: Fixes
118130

119-
- Only accept root ArgumentParser in `add_tui_command` [6f124f0]
120-
- Correct image name in docker-compose [bcbfcec]
131+
- Only accept root ArgumentParser in `add_tui_command` \[6f124f0\]
132+
- Correct image name in docker-compose \[bcbfcec\]
121133

122-
---
134+
______________________________________________________________________
123135

124136
## 0.1.0 - 2023-07-22
125137

126-
- Init fork as argparse-tui :rocket: [367bc96]
138+
- Init fork as argparse-tui :rocket: \[367bc96\]
127139

128140
### :clap: Features
129141

130-
- Argparse support [394d4dc]
131-
- Ctrl+y to copy command [99d24f2]
132-
- Add hacker keybindings [262f231]
133-
- Redact sensitive values [ca0df16]
134-
- Support click prompt_required [48809bf]
135-
- Omit hidden parameters and subcommands [0a7ed9d]
136-
- Support typer [705e432]
137-
- *Breaking:* Refactor to make click optional [91db7dd]
142+
- Argparse support \[394d4dc\]
143+
- Ctrl+y to copy command \[99d24f2\]
144+
- Add hacker keybindings \[262f231\]
145+
- Redact sensitive values \[ca0df16\]
146+
- Support click prompt_required \[48809bf\]
147+
- Omit hidden parameters and subcommands \[0a7ed9d\]
148+
- Support typer \[705e432\]
149+
- *Breaking:* Refactor to make click optional \[91db7dd\]
138150

139151
### :fist: Fixes
140152

141-
- Regain feature parity with trogon/main [ca15753]
142-
- Fixed command info when no docstring is present [d434653]
143-
- Fixed help_text if self.schema.help is none [f42f995]
153+
- Regain feature parity with trogon/main \[ca15753\]
154+
- Fixed command info when no docstring is present \[d434653\]
155+
- Fixed help_text if self.schema.help is none \[f42f995\]
144156

145157
### :point_right: Changes
146158

147-
- Generate `post_run_command` on-closed, not on-changed [afd8883]
159+
- Generate `post_run_command` on-closed, not on-changed \[afd8883\]

Dockerfile-docs renamed to Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.10.10-slim-bullseye as build
1+
FROM python:3.13.0-slim-bullseye as build
22
RUN apt-get update \
33
&& apt-get install --upgrade -y git build-essential gcc libssl-dev libffi-dev python3-dev
44
WORKDIR /workspace
@@ -9,6 +9,7 @@ RUN python3 -m pip install 'mkdocs==1.*' \
99
'mkdocs-jupyter' \
1010
'mkdocs-include-dir-to-nav' \
1111
'mkdocstrings[python]' \
12+
'black' \
1213
'mkdocs-autorefs' \
1314
'pymdown-extensions' \
1415
'pygments'

README.md

Lines changed: 79 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,125 @@
11
<h1 align="center">argparse-tui</h1>
2-
<p align="center"><em>Your Argparse CLI, now with a TUI.</em></p>
2+
<p align="center"><em>Present your Argparse CLI as a Textual UI (TUI).</em></p>
33
<h2 align="center">
44
<a href="https://www.f2dv.com/r/argparse-tui/" target="_blank">Documentation</a>
5-
| <a href="https://www.f2dv.com/s/argparse-tui/" target="_blank">Slide Deck</a>
65
| <a href="https://www.github.com/fresh2dev/argparse-tui/" target="_blank">Git Repo</a>
76
</h2>
87

9-
I was several months into developing my Python CLI framework, [Yapx](https://www.f2dv.com/r/yapx/), when I saw a [post on Hackernews](https://news.ycombinator.com/item?id=36020717) of an awesome tool, [Trogon](https://github.com/Textualize/trogon), which makes it effortless to create a TUI form for a Click CLI app. I was stunned; I knew I had to integrate it into Yapx. But Yapx is built on Python's native Argparse library, not Click. So, I forked Trogon and hacked away until it became this project, *argparse-tui*.
8+
`argparse-tui` is a Python package that can convert your Argparse CLI into a Textual UI (TUI). It is also able to provide a TUI interface to existing command-line apps using Argparse as a declarative DSL. This library is a soft-fork of [Trogon](https://github.com/Textualize/trogon), powered by the [Textual TUI framework](https://github.com/textualize/textual), refactored for use with Python's native *Argparse*, instead of *Click*.
9+
10+
______________________________________________________________________
11+
12+
<!-- TOC GFM -->
13+
14+
- [Distinguishing Features](#distinguishing-features)
15+
- [Vim-friendly Nav](#vim-friendly-nav)
16+
- [Redaction](#redaction)
17+
- [Pre-populating TUI](#pre-populating-tui)
18+
- [Use](#use)
19+
- [Examples](#examples)
20+
- [Install](#install)
21+
- [Related Projects](#related-projects)
22+
23+
<!-- /TOC -->
24+
25+
______________________________________________________________________
26+
27+
![](https://img.fresh2.dev/1691530009_42873ae0cbe.png){: style="width:60%;border:1px solid gray"}
28+
29+
## Distinguishing Features
30+
31+
This package also has these distinguishing features from it's upstream relative, Trogon:
32+
33+
### Vim-friendly Nav
34+
35+
- Move down / up using `j` / `k`.
36+
- `/` to focus search.
37+
- `Enter` to focus the selected command.
38+
- `Escape` to focus the command-tree.
39+
- `Ctrl+y` to copy the current command.
40+
41+
### Redaction
42+
43+
Redact sensitive values in the TUI by including the term `<secret>` in the argument's help text.
44+
45+
```python
46+
parser.add_argument("-p", "--password", help="<secret>")
47+
```
48+
49+
![](https://img.fresh2.dev/1691520889_8d13165a60d.png){: style="width:60%;border:1px solid gray"}
50+
51+
### Pre-populating TUI
52+
53+
Command-line args are used to filter and pre-populate the TUI form.
54+
55+
```shell
56+
$ awesome-app hello world --tui
57+
```
58+
59+
![](https://img.fresh2.dev/1691516124_211d67f1ea7.png){: style="width:60%;border:1px solid gray"}
60+
61+
## Use
1062

1163
*argparse-tui* can display a TUI of your Python Argparse CLI in one of two ways:
1264

13-
1. Display the TUI form directly:
65+
1. Add an argument (or command) to a parser that, when provided, displays the TUI form:
1466

1567
```python
1668
from argparse import ArgumentParser
17-
from argparse_tui import invoke_tui
69+
from argparse_tui import add_tui_argument
1870

1971
parser = ArgumentParser()
72+
add_tui_argument(parser)
2073
...
21-
invoke_tui(parser)
74+
parser.parse_args()
2275
```
2376

24-
2. Add an argument (or command) to the parser that, when provided, displays the TUI form:
77+
> This is useful when your CLI app is powered by Argparse and you want to display it as a Textual UI.
78+
79+
1. Display the TUI form directly:
2580

2681
```python
2782
from argparse import ArgumentParser
28-
from argparse_tui import add_tui_argument
83+
from argparse_tui import invoke_tui
2984

3085
parser = ArgumentParser()
31-
add_tui_argument(parser)
3286
...
33-
parser.parse_args()
87+
invoke_tui(parser)
3488
```
3589

36-
In addition to Argparse support, this fork adds some sweet features including:
90+
> This is useful when you are using Argparse as a declarative DSL to build a TUI which models an existing CLI application.
3791
38-
- Vim-friendly keybindings.
39-
- Redaction of secret values.
40-
- Pre-populating TUI fields with command-line argument values.
92+
## Examples
4193

42-
<a href="https://www.f2dv.com/s/argparse-tui/" target="_blank">
43-
<img src="https://img.fresh2.dev/slides_placeholder.png"></img>
44-
</a>
94+
Example scripts for Argparse, Yapx, are provided in the [`examples/`](https://github.com/fresh2dev/argparse-tui/tree/main/examples) directory.
4595

4696
## Install
4797

4898
```
4999
pip install argparse-tui
50100
```
51101

52-
## P.S.
102+
## Related Projects
103+
104+
- [fresh2dev/TUIview](https://www.f2dv.com/r/tuiview/) is a Python CLI that uses argparse-tui TUIs for existing CLI applications.
105+
106+
- [fresh2dev/yapx](https://www.f2dv.com/r/yapx/) is a Python library for building a Python CLI from your existing Python functions, with `argparse-tui` support built-in.
53107

54-
If you appreciate *argparse-tui*, check out [Yapx](https://www.f2dv.com/r/yapx/), [Myke](https://www.f2dv.com/r/myke/), and [TUIview](https://www.f2dv.com/r/tuiview/).
108+
- [fresh2dev/myke](https://www.f2dv.com/r/myke/) is a Python CLI that builds on argparse-tui and Yapx to serve as a task runner with a CLI and TUI interface.
55109

56-
---
110+
______________________________________________________________________
57111

58112
[![License](https://img.shields.io/github/license/fresh2dev/argparse-tui?color=blue&style=for-the-badge)](https://www.f2dv.com/r/argparse-tui/license/)
59113
[![GitHub tag (with filter)](https://img.shields.io/github/v/tag/fresh2dev/argparse-tui?filter=!*%5Ba-z%5D*&style=for-the-badge&label=Release&color=blue)](https://www.f2dv.com/r/argparse-tui/changelog/)
60114
[![GitHub last commit (branch)](https://img.shields.io/github/last-commit/fresh2dev/argparse-tui/main?style=for-the-badge&label=updated&color=blue)](https://www.f2dv.com/r/argparse-tui/changelog/)
61115
[![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)
116+
62117
<!-- [![Funding](https://img.shields.io/badge/funding-%24%24%24-blue?style=for-the-badge)](https://www.f2dv.com/fund/) -->
118+
63119
<!-- [![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/) -->
120+
64121
<!-- [![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/) -->
122+
65123
<!-- [![PyPI - Downloads](https://img.shields.io/pypi/dm/argparse-tui?color=blue&style=for-the-badge)](https://pypi.org/project/argparse-tui/) -->
124+
66125
<!-- [![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/) -->

compose.yaml.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ global:
1010
labels:
1111
kompose.controller.type: "deployment" # 'deployment' (default) or 'statefulset'
1212
# kompose.serviceaccount-name: "<{{$vars.releaseName}}>"
13-
image: '<{{ $vars.registry }}>/<{{ getenv "CI_PROJECT_PATH" | required "Missing required env var: CI_PROJECT_PATH" }}>-docs:<{{ getenv "CI_COMMIT_SHORT_SHA" | required "Missing required env var: CI_COMMIT_SHORT_SHA" }}>'
13+
image: '<{{ $vars.registry }}>/<{{ getenv "CI_PROJECT_PATH" | required "Missing required env var: CI_PROJECT_PATH" }}>:<{{ getenv "CI_COMMIT_SHORT_SHA" | required "Missing required env var: CI_COMMIT_SHORT_SHA" }}>'
1414
ports: ["<{{ $vars.svcPort }}>"]
1515
configs:
1616
- source: <{{$vars.releaseName}}>-nginx-config

0 commit comments

Comments
 (0)