Skip to content

Commit

Permalink
doc: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Donald Mellenbruch authored and Donald Mellenbruch committed Jul 13, 2023
1 parent 99d24f2 commit e5ebd60
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ https://github.com/Textualize/trogon/assets/554369/c9e5dabb-5624-45cb-8612-f6ecf
</details>


Trogon works with the popular Python libraries [Click](https://click.palletsprojects.com/) and [Typer](https://github.com/tiangolo/typer), and will support other libraries and languages in the future. Trogon is integrated into the Python libraries [yapx](https://github.com/fresh2dev/yapx) and [myke](https://github.com/fresh2dev/myke), and can even be used in conjunction with plain ol' `sys.argv`. See the `examples/` directory for examples of each.
Trogon works with the popular Python libraries [Argparse](https://docs.python.org/3/library/argparse.html), [Click](https://click.palletsprojects.com/), [Typer](https://github.com/tiangolo/typer), [Yapx](https://www.f2dv.com/code/r/yapx/i/), and [myke](https://www.f2dv.com/code/r/myke/i/), and will support other libraries and languages in the future. You can also manually build your own TUI schema and use it however you like, even in conjunction with `sys.argv`. See the `examples/` directory for examples of each.

## How it works

Expand Down Expand Up @@ -90,6 +90,8 @@ pip install trogon

## Quickstart

### Click

1. Import `from trogon.click import tui`
2. Add the `@tui` decorator above your click app. e.g.
```python
Expand All @@ -100,13 +102,30 @@ pip install trogon
```
3. Your click app will have a new `tui` command available.

### Argparse

1. Import `from trogon.argparse import add_tui_argument`
or, `from trogon.argparse import add_tui_command`
2. Add the TUI argument/command to your argparse parser. e.g.
```python
parser = argparse.ArgumentParser()

# add tui argument (my-cli --tui)
add_tui_argument(parser)
# and/or, add tui command (my-cli tui)
add_tui_command(parser)
```
3. Your argparse parser will have a new parameter `--tui` and/or a new command `tui`.

See also the `examples` folder for example apps.

## Custom command name and custom help

By default the command added will be called `tui` and the help text for it will be `Open Textual TUI.`

You can customize one or both of these using the `help=` and `command=` parameters:
You can customize one or both of these using the `help=` and `command=` parameters.

### Click

```python
@tui(command="ui", help="Open terminal UI")
Expand All @@ -115,6 +134,17 @@ def cli():
...
```

### Argparse

```python
parser = argparse.ArgumentParser()

# add tui argument (my-cli --tui)
add_tui_argument(parser, option_strings=["--ui"], help="Open terminal UI")
# and/or, add tui command (my-cli tui)
add_tui_command(parser, command="ui", help="Open terminal UI")
```

## Follow this project

If this app interests you, you may want to join the Textual [Discord server](https://discord.gg/Enf6Z3qhVr) where you can talk to Textual developers / community.

0 comments on commit e5ebd60

Please sign in to comment.