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 73be3e8049
chore: bumped version to v0.1.1
Signed-off-by: D. Moonfire <d.moonfire@moonfire.us>
2026-10-11 12:24:05 -05:00
.config chore: updating website documentation 2026-09-22 23:50:11 -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 chore: updated mfgames-project-setup to v2.0.1 2026-09-21 23:36:33 -05:00
.editorconfig chore: updated mfgames-project-setup to v2.0.1 2026-09-21 23:36: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 fix: updated dependency to avoid warning 2026-10-11 12:23:23 -05:00
Cargo.toml chore: bumped version to v0.1.1 2026-10-11 12:24:05 -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: updated mfgames-project-setup to v2.0.1 2026-09-21 23:36:33 -05:00
flake.nix chore: updated mfgames-project-setup to v2.0.1 2026-09-21 23:36:33 -05:00
Justfile chore: updated mfgames-project-setup to v2.0.1 2026-09-21 23:36:33 -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.