https://github.com/shresht7/go-cli-tools
Command-line tools and utilities for Go
https://github.com/shresht7/go-cli-tools
cli go
Last synced: 26 days ago
JSON representation
Command-line tools and utilities for Go
- Host: GitHub
- URL: https://github.com/shresht7/go-cli-tools
- Owner: Shresht7
- License: mit
- Created: 2022-01-30T14:44:57.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-02T10:56:54.000Z (about 2 years ago)
- Last Synced: 2025-03-22T08:48:46.573Z (about 1 year ago)
- Topics: cli, go
- Language: Go
- Homepage: https://pkg.go.dev/github.com/Shresht7/go-cli-tools
- Size: 79.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `go-cli-tools`
Command-line tools and utilities for Go projects.
[](https://pkg.go.dev/github.com/Shresht7/go-cli-tools)
Table of Contents
- [๐ฆ ANSI Modules](#-ansi-modules)
- [๐จ Colors](#-colors)
- [๐ Styles](#-styles)
- [โ Cursor](#-cursor)
- [๐งผ Clear](#-clear)
- [๐
ฐ RegExp](#-regexp)
- [๐ Helpers](#-helpers)
- [๐ญ Composition](#-composition)
- [๐ Format](#-format)
- [Align](#align)
- [HereDoc](#heredoc)
- [Pad](#pad)
- [๐ฆ Layout](#-layout)
- [โ Symbols](#-symbols)
- [โ Status](#-status)
- [๐ License](#-license)
---
## ๐ฆ ANSI Modules
### ๐จ Colors
The colors package allows you to style text with colors.
```go
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))
```
[โฌ Back to Top][top]
### ๐ Styles
The styles package allows you to format your text.
```go
import "github.com/Shresht7/go-cli-tools/ansi/styles"
fmt.Println(styles.Bold("GO"))
fmt.Println(styles.Hidden("Secret"))
```
[โฌ Back to Top][top]
### โ Cursor
The cursor package provides helper function for cursor manipulation.
```go
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))
```
[โฌ Back to Top][top]
### ๐งผ Clear
The clear package provides helper functions to clear the terminal.
```go
import "github.com/Shresht7/go-cli-tools/ansi/clear"
fmt.Println(clear.EntireLine)
fmt.Println(clear.Screen)
```
[โฌ Back to Top][top]
### ๐
ฐ RegExp
Regular expressions to capture ansi codes. The `Strip` helper function can remove all ansi escape codes from a string.
```go
import "github.com/Shresht7/go-cli-tools/ansi/codes"
var text string = "..."
text = codes.Strip(text)
fmt.Println(text)
```
[โฌ Back to Top][top]
---
## ๐ Helpers
### ๐ญ Composition
Composition helpers provide two utility functions compose and pipe that allow you to combine many ansi functions together.
```go
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!")
```
[โฌ Back to Top][top]
---
## ๐ Format
### Align
Align text to the left, center or right.
```go
import "github.com/Shresht7/go-cli-tools/format"
var text string = "..."
fmt.Println(format.Align(text, &format.AlignOptions{ Mode: "Center" }))
```
[โฌ Back to Top][top]
### HereDoc
HereDoc is a helper function to create a multi-line string.
```go
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.
```
[โฌ Back to Top][top]
### Pad
Apply padding around the text.
```go
import "github.com/Shresht7/go-cli-tools/format"
var text string = "..."
fmt.Println(format.Pad(text, " ", 5))
```
[โฌ Back to Top][top]
---
## ๐ฆ Layout
Create a table.
```go
import "github.com/Shresht7/go-cli-tools/layout"
var data [][]string // ...
table := layout.NewTable(data)
fmt.Println(table.String())
```
---
## โ Symbols
Unicode symbols for the terminal
```
โ โน โ โ โฐ โ โ โ โ โช โซ โ โ โค โฆ โบ โฒ โด โผ โพ โ โธ โ โฅ โ โ โ โ โค โฅ โก โ เทด โ
โถ โฌข
```
```go
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: โ โ โ โ
```
[โฌ Back to Top][top]
## โ Status
The `status` package includes some commonly used symbols with color.
```go
import "github.com/Shresht7/go-cli-tools/status"
fmt.Println(status.Tick, "Done") // โ Done
```
[โฌ Back to Top][top]
---
## ๐ License
This project is licensed under the [MIT License](LICENSE) - see the [LICENSE](LICENSE) file for details.
[top]: #go-cli-tools