Limner colorizes and transforms CLI outputs.

Related tags

Command Line limner
Overview

Limner

Limner colorizes and transforms CLI outputs.

Motivation

When playing with kubectl, I sometimes found it hard to extract the information I needed most from the extermely long, mono-colored output produced by the CLI. The same things happens when I'm using curl to test some REST APIs which usually return a long string of JSON.

Of course I can use GUI tools like Kubernetes Dashboard and Postman, but for simple operations that need to be performed swiftly, CLIs have their own advantages. Therefore, I made limner to bring some changes to the CLIs' output.

Installation

Download a release binary

Go to Release Page, download a release and run:

tar zxvf lm_[version]_[os]_[arch].tar.gz
cd lm_[version]_[os]_[arch]
mv ./lm_[os]_[arch] ./lm
chmod +x ./lm
[your command] | ./lm

Remember to replace the text in [].

Manual Installation

  1. You'll need Go installed.

  2. Clone the repo:

git clone https://github.com/SignorMercurio/limner.git
cd limner
go build -o lm .
  1. Run the command:
[your command] | ./lm

Note: It's strongly recommended to add the binary to your $PATH, e.g. /usr/local/bin.

Usage

Basic Usage

In most cases, you don't need to append any arguments when using limner as it automatically detects the format of the output.

Colorize tables:

kubectl get po | lm

Colorize YAML files:

cat nginx-deploy.yml | lm

Colorize JSON responses:

curl https://api.github.com/SignorMercurio | lm

TODO: Add support for more formats and transformation between different formats.

Create a shortcut

Take kubectl as an example.

Bash

Suppose you've already configured autocompletion for kubectl (Optional).

In your .bash_profile or .bashrc, append the following lines:

function k() {kubectl [email protected] | lm}
complete -o default -F __start_kubectl k

Zsh

Suppose you've already configured autocompletion for kubectl (Optional).

In your .zprofile or .zshrc, append the following lines:

function k() {kubectl [email protected] | lm}
compdef k=kubectl

After the above steps, you'll be able to use kubectl with color and autocompletion like:

k get po

Non-terminal output

When you choose to output the result to a file, or pass the result to other programs, through a pipe | or redirection >, you certainly do not want limner to colorize the output. The --plain flag (or -p) is meant for this, which prevent limner from colorizing the output.

Customize color themes

You can use a config file to customize color themes. By default, limner will try to read $HOME/.limner.yaml but you can specify the config file with -c, for example:

kubectl get po | lm -c config/limner.yml

And here's an example of config file, which uses the same color theme as the default one:

key_color: Red
string_color: Green
bool_color: Yellow
number_color: Yellow
null_color: Cyan
header_color: Blue
column_colors:
  - White
  - Cyan

Possible colors include Red, Green, Yellow, Cyan, Blue, Magenta, White and Black.

Enforce types on the output

Specify -t to force limner to view the output as a specific type: YAML / JSON / table, etc. For example:

kubectl describe deploy/nginx | lm -t yaml

Note: Specifying -t yaml in kubectl describe is not necessary.

Contributions

Any contributions are welcome. Please feel free to:

  • Open an Issue
  • Creating a Pull Request
  • Comment in an Issue / PR
  • Open a Discussion

Thank you for willing to contribute to this project!

Roadmap

  • Basic colorization
    • YAML
    • JSON
    • Tables
    • ...
  • Simple data format transformation
    • YAML <-> JSON
    • ...

If you have any suggestions for the project, please don't hesitate to open an issue or pull request.

LICENSE

Distributed under the MIT License. See LICENSE for more information.

Acknowledgements

Inspired by the following incredible projects:

You might also like...
A wrapper of aliyun-cli subcommand alidns, run aliyun-cli in Declarative mode.

aliyun-dns A wrapper of aliyun-cli subcommand alidns, run aliyun-cli in Declarative mode. Installation Install aliyun-cli. Usage $ aliyun-dns -h A wra

Symfony-cli - The Symfony CLI tool For Golang

Symfony CLI Install To install Symfony CLI, please download the appropriate vers

Cli-algorithm - A cli program with A&DS in go!

cli-algorithm Objectives The objective of this cli is to implement 4 basic algorithms to sort arrays been Merge Sort Insertion Sort Bubble Sort Quick

Nebulant-cli - Nebulant's CLI
Nebulant-cli - Nebulant's CLI

Nebulant CLI Website: https://nebulant.io Documentation: https://nebulant.io/docs.html The Nebulant CLI tool is a single binary that can be used as a

News-parser-cli - Simple CLI which allows you to receive news depending on the parameters passed to it
News-parser-cli - Simple CLI which allows you to receive news depending on the parameters passed to it

news-parser-cli Simple CLI which allows you to receive news depending on the par

bcrypt-cli is the CLI tool for hashing passwords with bcrypt.

bcrypt-cli bcrypt-cli is the CLI tool for hashing passwords with bcrypt. Install go install github.com/ryicoh/bcrypt-cli Usage It can be used like bas

Gobby-cli - CLI application to debug gobby applications

go(bby) Interactive debugging tool for gobby applications Usage Coming soonโ„ข Ins

GTDF-CLI - The official CLI tool to operate with Getting Things Done Framework
GTDF-CLI - The official CLI tool to operate with Getting Things Done Framework

This is the official CLI tool to operate with Getting Things Done Framework. How

CLI for Shamir's Secret Sharing and AES key generation, encryption, and decryption.
CLI for Shamir's Secret Sharing and AES key generation, encryption, and decryption.

Shush ๐Ÿคซ This simple program will help you run Shamir's Secret Sharing algorithm on any file using the split and merge commands.

Comments
  • [ImgBot] Optimize images

    [ImgBot] Optimize images

    Beep boop. Your images are optimized!

    Your image file size has been reduced by 30% ๐ŸŽ‰

    Details

    | File | Before | After | Percent reduction | |:--|:--|:--|:--| | /img/logo.png | 23.77kb | 12.18kb | 48.75% | | /img/shortcut.png | 106.86kb | 69.81kb | 34.67% | | /img/yml2json.png | 254.76kb | 168.21kb | 33.98% | | /img/table.png | 86.81kb | 57.58kb | 33.67% | | /img/yml.png | 427.11kb | 297.06kb | 30.45% | | /img/json2yml.png | 312.80kb | 220.04kb | 29.65% | | /img/json.png | 702.85kb | 518.79kb | 26.19% | | | | | | | Total : | 1,914.96kb | 1,343.66kb | 29.83% |


    ๐Ÿ“ docs | :octocat: repo | ๐Ÿ™‹๐Ÿพ issues | ๐Ÿช marketplace

    ~Imgbot - Part of Optimole family

    opened by imgbot[bot] 1
Releases(v0.2.0)
Owner
Mercurio
MSc
Mercurio
Go program that outputs a GIF with the lissajous figures using green and black

lissajousgb This is an exercise of the book The Go Programming Language, by Alan

Santiago Rodriguez 0 Dec 18, 2021
simple clipboard copy for complex outputs

Terminal Clipboard Different from others terminal's clipboard coppiers, this one can copy complex and interminables commands like tail -f or outputs t

Daniel Kanczuk 0 Nov 5, 2021
A piece of software that shouldn't need to exist. Processes badly formatted outputs from Morgan Stanley Shareworks into usable CSV files.

Shareworks-munger: A program to process Shareworks reports into Something Usable "Shareworks" is a product of Morgan Stanley which tracks certain kind

Eric Myhre 10 Jun 6, 2022
Go-file-downloader-ftctl - A file downloader cli built using golang. Makes use of cobra for building the cli and go concurrent feature to download files.

ftctl This is a file downloader cli written in Golang which uses the concurrent feature of go to download files. The cli is built using cobra. How to

Dipto Chakrabarty 2 Jan 2, 2022
Go-api-cli - Small CLI to fetch data from an API sync and async

Async API Cli CLI to fetch data on "todos" from a given API in a number of ways.

Pete Robinson 0 Jan 13, 2022
Syno-cli - Synology unofficial API CLI and library

Synology CLI Unofficial wrapper over Synology API in Go. Focus on administrative

Aleksandr Baryshnikov 14 Sep 6, 2022
Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

Katz 1 Jan 12, 2022
Elegant CLI wrapper for kubeseal CLI

Overview This is a wrapper CLI ofkubeseal CLI, specifically the raw mode. If you just need to encrypt your secret on RAW mode, this CLI will be the ea

Elm 4 Jan 8, 2022
CLI to run a docker image with R. CLI built using cobra library in go.

BlueBeak Installation Guide Task 1: Building the CLI The directory structure looks like Fastest process: 1)cd into bbtools 2)cd into bbtools/bin 3)I h

Aniruddha Chattopadhyay 0 Dec 20, 2021