utilities/snippets_cli_go#3: Tabulated output



Issue Information

Issue Type: issue
Status: closed
Reported By: btasker
Assigned To: btasker

Milestone: v0.1
Created: 27-Sep-24 09:40



Description

In the original script, results are tabulated

ben@optimus:~$ sbt_cli lua
Search results - String: lua, title: False, lang: False, similarto: False
| Snippet ID | Title                                         | Language |
|-----------------------------------------------------------------------|
| 142        | Check if value exists in table                | LUA      |
| 133        | Connect to HTTPS upstream with lua-resty-http | LUA      |
| 101        | Check if variable is numeric                  | LUA      |
| 96         | Urldecode string                              | LUA      |
| 83         | Recursively print table (print_r equivalent)  | LUA      |
| 40         | Check if variable is table                    | LUA      |
| 26         | Imploding a table                             | LUA      |
| 18         | Trim whitespace from string                   | LUA      |
| 17         | Trim whitespace from beginning of string      | LUA      |
| 14         | Trim whitespace from end of string            | LUA      |
| 13         | Split string on Delimiter                     | LUA      |
| 12         | Check if table has element                    | LUA      |
-------------------------------------------------------------------------

We should do the same here



Toggle State Changes

Activity


assigned to @btasker

verified

mentioned in commit 47da29cba6ae1cebcbc8639731758ddfa3c20eb3

Commit: 47da29cba6ae1cebcbc8639731758ddfa3c20eb3 
Author: B Tasker                            
                            
Date: 2024-09-27T10:56:55.000+01:00 

Message

feat: create a tabulated output view (utilities/snippets_cli_go#3)

+57 -4 (61 lines changed)

Output from the commit above looks like this

+---------------------------------------------------------------------------+
| Search results: foo                                                       |
+---+------------------------------------------------------------+----------+
| # | TITLE                                                      | LANGUAGE |
+---+------------------------------------------------------------+----------+
| 1 | I'm a Pylontech Recommended Technician... Wait, Wut?       | N/A      |
| 1 | Unclogging A Washing Machine When The Pump Cover Is Jammed | N/A      |
| 1 | Building a Raspberry Pi Cycling Computer                   | N/A      |
| 1 | Migrating a HTML based site to Markdown                    | N/A      |
| 1 | Mini Cooper: Tire Pressure Warning Reset                   | N/A      |
| 1 | Should've Bought A Playstation                             | N/A      |
| 1 | Automating against Link Rot                                | N/A      |
| 1 | Running Linkwarden in Kubernetes                           | N/A      |
| 1 | Building My Own Streaming TV Station                       | N/A      |
| 1 | Deploying InfluxDB and Telegraf to Monitor Kubernetes      | N/A      |
+---+------------------------------------------------------------+----------+

go-pretty is quite flexible, so we can change the table style (and even add colours) if we want.