Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ewels authored Dec 20, 2024
1 parent 1e3635c commit 44b4267
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
6 changes: 3 additions & 3 deletions docs/documentation/accessibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ NO_COLOR=1 python cli.py

And this will disable all colors in **rich-click**.

You can also add `NO_COLOR=1` to your `~/.bashrc` (if using bash) or `~/.zshrc` (if using zsh):
You can also add `export NO_COLOR=1` to your `~/.bashrc` (if using bash) or `~/.zshrc` (if using zsh) for it to be set automatically every time you open a new terminal shell:

```shell
# If using bash:
echo "NO_COLOR=1" > ~/.bashrc
echo "export NO_COLOR=1" >> ~/.bashrc

# If using zsh:
echo "NO_COLOR=1" > ~/.zshrc
echo "export NO_COLOR=1" >> ~/.zshrc
```

## Colorblindness accessibility considerations for developers
Expand Down
34 changes: 18 additions & 16 deletions docs/documentation/comparison_of_click_and_rich_click.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,41 @@ The only change to these decorators is that by default, their `cls=` parameters

You can still access the base Click classes by their original names:

- `from rich_click import Command`
- `from rich_click import Group`
- `from rich_click import Context`
```python
from rich_click import Command, Group, Context
```

The above are the same as importing from `click`.

**rich-click**'s subclasses all have the word Rich in front of them!

- `from rich_click import RichCommand`
- `from rich_click import RichGroup`
- `from rich_click import RichContext`
```python
from rich_click import RichCommand, RichGroup, RichContext
```

### Echo and interactive elements

**rich-click** deliberately does _not_ enrich certain Click features:

- `click.echo()`
- `click.echo_via_pager()`
- `click.confirm()`
- `click.prompt()`
```python
click.echo()
click.echo_via_pager()
click.confirm()
click.prompt()
```

You are free to use these functions and they are available via `import rich_click as click`,
You are free to use these functions and they are available via `#!python import rich_click as click`,
but Rich's markup will not work with these functions because these functions are just the base Click implementations,
without any changes.

This is a deliberate decision that we are unlikely to change in the future.
We do not want to maintain a more spread-out API surface, and we encourage users to become comfortable using Rich directly; it's a great library and it's worth learning a little bit about it!
If you'd like Rich markup for your echos and interactive elements, then you can:

- Replace `click.echo()` with `rich.print()`
- Replace `click.echo_via_pager()` with `rich.Console().pager()`
- Replace `click.confirm()` with `rich.prompt.Confirm.ask()`
- Replace `click.prompt()` with `rich.prompt.Prompt.ask()`
- Replace `#!python click.echo()` with `#!python rich.print()` ([docs](https://rich.readthedocs.io/en/stable/introduction.html#quick-start))
- Replace `#!python click.echo_via_pager()` with `#!python rich.Console().pager()` ([docs](https://rich.readthedocs.io/en/stable/console.html#paging))
- Replace `#!python click.confirm()` with `#!python rich.prompt.Confirm.ask()` ([docs](https://rich.readthedocs.io/en/stable/prompt.html))
- Replace `#!python click.prompt()` with `#!python rich.prompt.Prompt.ask()` ([docs](https://rich.readthedocs.io/en/stable/prompt.html))

Below is a side-by-side comparison of Click and Rich implementations of echos and interactive elements in **rich-click**:

Expand Down Expand Up @@ -92,7 +94,7 @@ Below is a side-by-side comparison of Click and Rich implementations of echos an
name = Prompt.ask("[blue]What is your name?[/]")

if not Confirm.ask("[blue]Are you sure?[/]"):
rich.print("[red]Aborting[/]"))
rich.print("[red]Aborting[/]")
return

rich.print(f"[green]Hello, {name}![/]")
Expand Down

0 comments on commit 44b4267

Please sign in to comment.