﻿<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="text" xml:lang="en">mfgames-cli-table</title>
  <link type="application/atom+xml" href="https://mfgames.com/mfgames-cli-table-rs/atom.xml" rel="self" />
  <link type="text/html" href="https://mfgames.com/mfgames-cli-table-rs/" rel="alternate" />
  <updated>2026-09-20T21:12:00Z</updated>
  <id>https://mfgames.com/mfgames-cli-table-rs/</id>
  <author>
    <name>D. Moonfire</name>
  </author>
  <rights>Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International</rights>
  <entry>
    <title>Introducing mfgames-cli-table for Rust (mfgames-cli-table)</title>
    <link rel="alternate" href="https://mfgames.com/blog/2026/09/18/introducing/" />
    <updated>2026-09-18T05:00:00Z</updated>
    <id>https://mfgames.com/blog/2026/09/18/introducing/</id>
    <category term="mfgames-cli-table" scheme="https://mfgames.com/categories/" label="mfgames-cli-table" />
    <content type="html">&lt;p&gt;One of the guiding principles of our development is the &lt;a href="https://en.wikipedia.org/wiki/Rule_of_three_(computer_programming)"&gt;Rule of Three&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Three strikes and then you refactor.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In this case, a common pattern in our CLI's is generating tables. While this is relatively simple at the moment, it can quickly become complex. For example, we normally like our tables to be simple:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-sh"&gt;$ just example-basic
 name   value
 alfa   1
 bravo  2
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But there are times when we want to dump it to Markdown or JSON:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-sh"&gt;$ just example-basic --markdown
| name  | value |
|-------|-------|
| alfa  | 1     |
| bravo | 2     |

$ just example-basic --json | jq
[
  {
    &amp;quot;name&amp;quot;: &amp;quot;alfa&amp;quot;,
    &amp;quot;value&amp;quot;: 1
  },
  {
    &amp;quot;name&amp;quot;: &amp;quot;bravo&amp;quot;,
    &amp;quot;value&amp;quot;: 2
  }
]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At the moment, there isn't much to this beyond what is displayed but we've created the same libraries in different languages and purposes, so we know that this has the potential of being more featured as time progresses. And it would be better to make it central now so we don't have to reinvent the wheel later.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Writing out to YAML&lt;/li&gt;
&lt;li&gt;Adding/removing columns&lt;/li&gt;
&lt;li&gt;Sort the output based on columns&lt;/li&gt;
&lt;li&gt;Basic filtering&lt;/li&gt;
&lt;li&gt;Right-align numbers in displayed tables&lt;/li&gt;
&lt;li&gt;Dot-align decimals&lt;/li&gt;
&lt;li&gt;Sending the table output to a file&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
</feed>
