https://github.com/keyneston/mktable
Format CLI data into Markdown Tables
https://github.com/keyneston/mktable
cli formatting golang markdown markdown-table
Last synced: 4 months ago
JSON representation
Format CLI data into Markdown Tables
- Host: GitHub
- URL: https://github.com/keyneston/mktable
- Owner: keyneston
- License: bsd-3-clause
- Created: 2021-04-20T16:36:35.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-06-23T12:25:44.000Z (almost 4 years ago)
- Last Synced: 2025-11-06T02:42:38.804Z (6 months ago)
- Topics: cli, formatting, golang, markdown, markdown-table
- Language: Go
- Homepage:
- Size: 43 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mktable
[](https://github.com/keyneston/mktable/actions/workflows/go.yml)
`mktable` is a simplish cli tool which consumes content via STDIN and converts
it into a pretty aligned table ready for use in markdown.
# Installation
```shell
brew tap keyneston/tap
brew install mktable
```
With go installed:
```shell
go install github.com/keyneston/mktable@latest
```
Or download the [latest release](https://github.com/keyneston/mktable/releases/) and add to your path.
# Use
```
$ netstat -i | head -5 | mktable -s ' +'
| Name | Mtu | Network | Address | Ipkts | Ierrs | Opkts | Oerrs | Coll |
| ---- | ----- | ----------- | --------- | ------- | ------- | ------- | ----- | ---- |
| lo0 | 16384 | | 9583572 | 0 | 9583572 | 0 | 0 | |
| lo0 | 16384 | 127 | localhost | 9583572 | - | 9583572 | - | - |
| lo0 | 16384 | localhost | ::1 | 9583572 | - | 9583572 | - | - |
| lo0 | 16384 | keyport.loc | fe80:1::1 | 9583572 | - | 9583572 | - | - |
```
## Flags
| Flag | Default | Description |
| ------------------ | ---------------- | -------------------------------------------------------------- |
| `-s` | `[ \t]*\t[ \t]*` | Regexp used to set the delimiter |
| `-no-headers` | `false` | Skip printing headers |
| `-r` / `-reformat` | `false` | Reformat existing markdown table. Alias for `-format mk` |
| `-a` | none | Sets the alignment. See [Alignment](#alignment) |
| `-f` / `-format` | `regexp` | Sets the input format. See [Formats](#format) for more details |
## Formats
| Format | Description |
| ----------------- | --------------------------------------------------- |
| `re` / `regexp` | Regular Expression Delimiter |
| `csv` | Comma Separated List |
| `mk` / `markdown` | Consume an existing markdown table for reformatting |
## Alignment
**EXPERIMENTAL**
The alignment flag can be passed multiple times and/or passed as a comma
seperated list.
It takes a number indicating a zero indexed column, and a character
indicating how to align the column.
| char | alignment |
| ---- | --------- |
| `>` | right |
| `<` | left |
| `=` | center |
### Examples
| Example | Description |
| -------------------- | ------------------------------------------------------- |
| `-a '0<'` | left align the 1st column |
| `-a '1='` | center align the 2nd column |
| `-a '1=,2>'` | center align the 2nd column, and right align the second |
| `-a '1=,2>' -a '3='` | as above, but also center align the 4th column |
## Reformat existing tables
```
$ mktable -r <