clifmt/README.md

204 lines
4.0 KiB
Markdown
Raw Normal View History

2019-01-25 11:19:06 +00:00
# | extended terminal format |
[![Go version](https://img.shields.io/badge/go_version-1.11-blue.svg)](https://golang.org/doc/go1.11)
[![Go Report Card](https://goreportcard.com/badge/git.xdrm.io/go/clifmt)](https://goreportcard.com/report/git.xdrm.io/go/clifmt)
[![Go doc](https://godoc.org/git.xdrm.io/go/clifmt?status.svg)](https://godoc.org/git.xdrm.io/go/clifmt)
2019-01-27 10:39:30 +00:00
[![buddy branch](https://app.buddy.works/xdrmbracketsdev/clifmt/repository/branch/master/badge.svg?token=33f90a953be299fc439c760e2eab36c708f8ea1f87f1159dd77924589b364b2d "buddy branch")](https://app.buddy.works/xdrmbracketsdev/clifmt/repository/branch/master)
2019-01-25 11:19:06 +00:00
Simple utility written in `go` that extends the standard `fmt.Sprintf` and `fmt.Printf` functions. It allows you to set foreground/background color, **bold**, <u>underlined</u> and _italic_ text.
<!-- toc -->
- [(1) Format](#1-format)
2019-01-27 16:04:45 +00:00
* [[Colorization]](#colorization)
+ [Base format](#base-format)
* [Example](#example)
+ [Foreground only](#foreground-only)
* [Example](#example-1)
+ [Background only](#background-only)
* [Example](#example-2)
* [[Markdown-like format]](#markdown-like-format)
+ [Bold format](#bold-format)
* [Example](#example-3)
+ [Italic format](#italic-format)
* [Example](#example-4)
+ [Underline format](#underline-format)
* [Example](#example-5)
+ [Hyperlink format](#hyperlink-format)
* [Example](#example-6)
- [(2) Screenshot](#2-screenshot)
2019-01-27 16:04:45 +00:00
* [Colorizing format example :](#colorizing-format-example-)
* [Markdown-like format example](#markdown-like-format-example)
- [(3) Incoming features](#3-incoming-features)
<!-- tocstop -->
2019-01-25 11:19:06 +00:00
----
## (1) Format
### [Colorization]
#### Base format
2019-01-25 11:19:06 +00:00
```go
${<target text>}(<fg>:<bg>)
```
- `<target text>` is the text that will be colorized.
2019-01-25 11:22:21 +00:00
2019-01-25 11:19:06 +00:00
- `<fg>` is the name of the foreground color (*c.f. [color list](https://git.xdrm.io/go/clifmt/src/master/colors.go#L15)*), or an hex color (*e.g.`#00ffaa`, `#0fa`*).
2019-01-25 11:22:21 +00:00
2019-01-25 11:19:06 +00:00
- `<bg>` is the name of the background color with the same syntax as for the foreground.
2019-01-25 11:22:21 +00:00
###### Example
```go
clifmt.Printf("normal text ${red text over black}(red:#000) normal text")
```
2019-01-25 11:19:06 +00:00
> Note that it is not recommended to nest the different coloring formats.
#### Foreground only
2019-01-25 11:19:06 +00:00
```go
${<target text>}(<fg>)
```
- `<target text>` is the text that will be colorized.
- `<fg>` is the name of the foreground color.
2019-01-25 11:22:21 +00:00
###### Example
```go
clifmt.Printf("normal text ${red text}(red) normal text")
```
#### Background only
2019-01-25 11:19:06 +00:00
```go
${<target text>}(:<bg>)
```
- `<target text>` is the text that will be colorized.
- `<bg>` is the name of the background color.
2019-01-25 11:22:21 +00:00
###### Example
```go
clifmt.Printf("normal text ${text over red}(#ff0000) normal text")
```
2019-01-25 11:19:06 +00:00
### [Markdown-like format]
#### Bold format
```go
**<target text>**
```
- `<target text>` is the text that will be bold.
###### Example
```go
clifmt.Printf("normal text **bold text** normal text")
```
#### Italic format
```go
*<target text>*
```
- `<target text>` is the text that will be italic.
###### Example
```go
clifmt.Printf("normal text *italic text* normal text")
```
#### Underline format
```go
_<target text>_
```
- `<target text>` is the text that will be underlined.
###### Example
```go
clifmt.Printf("normal text _underline text_ normal text")
```
2019-01-27 16:04:45 +00:00
#### Hyperlink format
```go
[<target text>](<target url>)
```
- `<target text>` is the text that will be displayed.
- `<target url>` is the url the hyperlink links to.
###### Example
```go
clifmt.Printf("normal text [hyper](link) normal text")
```
2019-01-25 11:19:06 +00:00
----
## (2) Screenshot
###### Colorizing format example :
![colorizing example](https://0x0.st/sCPc.png)
###### Markdown-like format example
![markdown-like example](https://0x0.st/sC9F.png)
2019-01-25 11:19:06 +00:00
----
## (3) Incoming features
- [x] **markdown-like formatting** - bold, italic, underlined, (strike-through?)
2019-01-25 11:19:06 +00:00
- [ ] **global alignment** - align text dynamically
- [ ] **progress-line** - redrawing format to show, for instance an animated progress bar on the same line