Giter Club home page Giter Club logo

go-pretty's Introduction

go-pretty

Go Reference Build Status Coverage Status Go Report Card Quality Gate Status

Utilities to prettify console output of tables, lists, progress-bars, text, etc. with a heavy emphasis on customization.

Usage

The current major version of this package is v6, and it follows the standard outlined here.

Run go get github.com/jedib0t/go-pretty/v6 to add this as a dependency to your project, and import the packages in your code using one or more of these:

  • github.com/jedib0t/go-pretty/v6/list
  • github.com/jedib0t/go-pretty/v6/progress
  • github.com/jedib0t/go-pretty/v6/table
  • github.com/jedib0t/go-pretty/v6/text

Table

Pretty-print tables in a terminal with colors, nested tables and more.

+-----+------------+-----------+--------+-----------------------------+
|   # | FIRST NAME | LAST NAME | SALARY |                             |
+-----+------------+-----------+--------+-----------------------------+
|   1 | Arya       | Stark     |   3000 |                             |
|  20 | Jon        | Snow      |   2000 | You know nothing, Jon Snow! |
| 300 | Tyrion     | Lannister |   5000 |                             |
+-----+------------+-----------+--------+-----------------------------+
|     |            | TOTAL     |  10000 |                             |
+-----+------------+-----------+--------+-----------------------------+

Table with Colors in a Terminal

More details can be found here: table/

Progress

Track the Progress of one or more Tasks like downloading multiple files in parallel.

Progress Demo in a Terminal

More details can be found here: progress/

List

Pretty-print lists with multiple levels/indents into ASCII/Unicode strings.

╭─ Game Of Thrones
│  ├─ Winter
│  ├─ Is
│  ╰─ Coming
│     ├─ This
│     ├─ Is
│     ╰─ Known
╰─ The Dark Tower
   ╰─ The Gunslinger

More details can be found here: list/

Text

Utility functions to manipulate text with or without ANSI escape sequences. Most of the functions available are used in one or more of the other packages here.

GoDoc has examples for all the available functions.

Upgrading from v5 or less to v6 or above

If you are using a version of this library older than v6.0.0 and want to move to a newer version of this library, you'd have to modify the import paths from something like:

    "github.com/jedib0t/go-pretty/list"
    "github.com/jedib0t/go-pretty/progress"
    "github.com/jedib0t/go-pretty/table"
    "github.com/jedib0t/go-pretty/text"

to:

    "github.com/jedib0t/go-pretty/v6/list"
    "github.com/jedib0t/go-pretty/v6/progress"
    "github.com/jedib0t/go-pretty/v6/table"
    "github.com/jedib0t/go-pretty/v6/text"

I'd recommend you fire up your favorite IDE and do a mass search and replace for all occurrences of jedib0t/go-pretty/ to jedib0t/go-pretty/v6/. If you are on a system with access to find, grep, xargs and sed, you could just run the following from within your code folder to do the same:

find . -type f -name "*.go" | grep -v vendor | xargs sed -i 's/jedib0t\/go-pretty\//jedib0t\/go-pretty\/v6\//g'

If you are on MacOS, you'll have to use sed -i '' instead of sed -i.

go-pretty's People

Contributors

eclipseo avatar ferryvg avatar jedib0t avatar mneira10 avatar titanous avatar virtuald avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.