Shresht7 / go-cli-tools

Command-line tools and utilities for Go

Home Page:https://pkg.go.dev/github.com/Shresht7/go-cli-tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-cli-tools

Command-line tools and utilities for Go projects.

Table of Contents

πŸ“¦ ANSI Modules

🎨 Colors

The colors package allows you to style text with colors.

import "github.com/Shresht7/go-cli-tools/ansi/colors"

fmt.Println(colors.Red("Giant"))
fmt.Println(colors.BgWhite("Dwarf"))
fmt.Println(colors.RGB("Supernova", 224, 65, 137))

πŸ’„ Styles

The styles package allows you to format your text.

import "github.com/Shresht7/go-cli-tools/ansi/styles"

fmt.Println(styles.Bold("GO"))
fmt.Println(styles.Hidden("Secret"))

☝ Cursor

The cursor package provides helper function for cursor manipulation.

import "github.com/Shresht7/go-cli-tools/ansi/cursor"

fmt.Print(cursor.ToPos(15, 20))
fmt.Print(cursor.Up(3))
fmt.Print(cursor.ToNextLine(5))

🧼 Clear

The clear package provides helper functions to clear the terminal.

import "github.com/Shresht7/go-cli-tools/ansi/clear"

fmt.Println(clear.EntireLine)
fmt.Println(clear.Screen)

πŸ…° RegExp

Regular expressions to capture ansi codes. The Strip helper function can remove all ansi escape codes from a string.

import "github.com/Shresht7/go-cli-tools/ansi/codes"

var text string = "..."
text = codes.Strip(text)
fmt.Println(text)

πŸ“š Helpers

🏭 Composition

Composition helpers provide two utility functions compose and pipe that allow you to combine many ansi functions together.

import "github.com/Shresht7/go-cli-tools/helpers"
import "github.com/Shresht7/go-cli-tools/ansi/colors"
import "github.com/Shresht7/go-cli-tools/ansi/styles"

styler = helpers.Compose(colors.Blue, styles.Bold, colors.BgWhite)
text = styler("Function Composition!")

πŸ“ƒ Format

Align

Align text to the left, center or right.

import "github.com/Shresht7/go-cli-tools/format"
var text string = "..."
fmt.Println(format.Align(text, &format.AlignOptions{ Mode: "Center" }))

HereDoc

HereDoc is a helper function to create a multi-line string.

import "github.com/Shresht7/go-cli-tools/format"
var text string = format.HereDoc(`
    This is a multi-line string
    that can be used to create
      a template.
`)
// Output:
// This is a multi-line string
// that can be used to create
//  a template.

Pad

Apply padding around the text.

import "github.com/Shresht7/go-cli-tools/format"
var text string = "..."
fmt.Println(format.Pad(text, " ", 5))

βœ” Symbols

Unicode symbols for the terminal

βœ” β„Ή ⚠ βœ– ☰ ↑ ↓ ← β†’ β™ͺ β™« β–  ● β€€ … β€Ί β–² β–΄ β–Ό β–Ύ β—‚ β–Έ βŒ‚ β™₯ ↔ ↕ β‰ˆ β‰  ≀ β‰₯ ≑ ∞ ΰ·΄ β˜… β–Ά β¬’
import "github.com/Shresht7/go-cli-tools/symbols"

fmt.Println(symbols.Warning, "Are you sure?")
//  ⚠ Are you sure?

fmt.Println(symbols.Tick, "Done")
//  βœ” Done

fmt.Println("Controls: ", symbols.ArrowUp, symbols.ArrowDown, symbol.ArrowLeft, symbols.ArrowRight)
//  Controls: ↑ ↓ ← β†’

βœ” Status

The status package includes some commonly used symbols with color.

import "github.com/Shresht7/go-cli-tools/status"

fmt.Println(status.Tick, "Done")  //  βœ” Done

πŸ“‘ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Command-line tools and utilities for Go

https://pkg.go.dev/github.com/Shresht7/go-cli-tools

License:MIT License


Languages

Language:Go 100.0%