Skip to content

Commit

Permalink
table support
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Feb 6, 2022
1 parent 1bafb5e commit e23666f
Show file tree
Hide file tree
Showing 10 changed files with 1,490 additions and 26 deletions.
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ You can specify a [theme](https://pygments.org/styles/) with `--theme`.
rich loop.py --theme dracula
```

You can set the default theme via the `RICH_THEME` environment variable. So the following is equivalent to the above command:

```
RICH_THEME=dracula rich loop.py
```

![syntax3](https://raw.githubusercontent.com/Textualize/rich-cli/main/imgs/syntax3.png)

By default, `rich` will wrap lines if they don't fit within the available width. You can disable this behavior with `--no-wrap`.
Expand All @@ -60,10 +66,10 @@ By default, `rich` will wrap lines if they don't fit within the available width.

## Markdown

You can request markdown rendering by adding the `--markdown` switch or `-m`.
You can request markdown rendering by adding the `--markdown` switch or `-m`. If the file ends with `.md` markdown will be auto-detected.

```
rich README.md -m
rich README.md
```

![markdown1](https://raw.githubusercontent.com/Textualize/rich-cli/main/imgs/markdown1.png)
Expand All @@ -76,14 +82,24 @@ rich README.md --hyperlinks

## JSON

You can request JSON pretty formatting and highlighting with the `--json` or `-j` switches.
You can request JSON pretty formatting and highlighting with the `--json` or `-j` switches. If the file ends with `.json` then JSON will be auto-detected.

```
rich cats.json --json
rich cats.json
```

![json1](https://raw.githubusercontent.com/Textualize/rich-cli/main/imgs/json1.png)

## CSV

Rich can display the contents of a CSV (or TSV) as a table. If the file ends with `.csv` or `.tsv` then JSON will be auto-detected.

```
rich deniro.csv
```

![csv1](https://raw.githubusercontent.com/Textualize/rich-cli/main/imgs/csv1.png)

### Rules

You can render a horizontal rule with `--rule` or `-u`. Specify a rule style with `--rule-style`. Set the character(s) to render the line with `--rule-char`.
Expand Down
Binary file added imgs/csv1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 68 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ rich = "^11.0.0"
click = "^8.0.0"
requests = "^2.0.0"
textual = "^0.1.15"
rich-rst = "^0.2.5"

[tool.poetry.dev-dependencies]
black = "21.12b0"
mypy = "^0.931"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
Loading

0 comments on commit e23666f

Please sign in to comment.