No description
  • Rust 64.7%
  • Nix 23.3%
  • Just 12%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
D. Moonfire 624ef4027d
docs: updating read me and news
Signed-off-by: D. Moonfire <d.moonfire@moonfire.us>
2026-09-20 15:49:41 -05:00
.config docs: updating read me and news 2026-09-20 15:49:41 -05:00
examples chore: added an example to play with the output 2026-09-18 20:44:11 -05:00
LICENSES chore: set up REUSE for licenses 2026-09-18 20:37:18 -05:00
news docs: updating read me and news 2026-09-20 15:49:41 -05:00
src docs: updating read me and news 2026-09-20 15:49:41 -05:00
.editorconfig chore: initial commit 2026-09-18 20:33:33 -05:00
.envrc chore: initial commit 2026-09-18 20:33:33 -05:00
.gitignore chore: initial commit 2026-09-18 20:33:33 -05:00
.prettierignore chore: initial commit 2026-09-18 20:33:33 -05:00
Cargo.lock chore: bumping dependencies 2026-09-18 20:38:12 -05:00
Cargo.toml chore: initial commit 2026-09-18 20:33:33 -05:00
CODE_OF_CONDUCT.md chore: initial commit 2026-09-18 20:33:33 -05:00
DCO.md chore: initial commit 2026-09-18 20:33:33 -05:00
flake.lock chore: initial commit 2026-09-18 20:33:33 -05:00
flake.nix chore: set up REUSE for licenses 2026-09-18 20:37:18 -05:00
Justfile build: add Just targets for building and testing 2026-09-18 20:53:53 -05:00
README.md docs: updating read me and news 2026-09-20 15:49:41 -05:00
REUSE.toml chore: set up REUSE for licenses 2026-09-18 20:37:18 -05:00
rust-toolchain.toml chore: initial commit 2026-09-18 20:33:33 -05:00

mfgames-cli-table

Generic list/table output formatting for clap-based CLI commands, built on tabled.

Usage

Add this package to the appropriate Cargo.toml:

mfgames-cli-table = { git = "https://src.mfgames.com/mfgames-rs/mfgames-cli-table.git" }

Command Arguments

This library contains a common set of options for clap that have no short form to avoid collisions:

  • --markdown formats the table in Markdown
  • --json formats the table in JSON
  • --format FORMAT formats the table in the given format:
    • none doesn't output the data at all
    • plain a plain format with minimal borders
    • markdown formats it as Markdown
    • json formats it as a single line JSON (format with jq if you need it pretty)

The three top-level arguments are mutually exclusive and all output always goes to stdout.

Printing

To format the data, take a Vec of row data that derived Tabled (for the table formatting) and Serialize (for JSON) and pass it into print_table:

#[derive(Tabled, Serialize)]
struct Row
{
    name: String,
}

fn run(command: &ListCommand)
{
    let rows = vec![Row { name: "example".into() }];
    print_table(rows, &command.table_options);
}

There is also a render_table which does the same but instead of printing it, it returns it as a string.