Updated README

This commit is contained in:
2023-08-13 20:02:03 +02:00
parent 0c558b561a
commit 8b69ca6de9
2 changed files with 51 additions and 47 deletions

View File

@@ -7,7 +7,7 @@ build:
export GO11MODULE="auto" \ export GO11MODULE="auto" \
go mod download; \ go mod download; \
go mod vendor; \ go mod vendor; \
CGO_ENABLED=0 go build -a -ldflags '-s' -installsuffix cgo -o motd-larry cmd/figlet4go/main.go CGO_ENABLED=0 go build -a -ldflags '-s' -installsuffix cgo -o motd cmd/motdGO/main.go
install: install:
export GO11MODULE="on"; \ export GO11MODULE="on"; \

View File

@@ -1,39 +1,57 @@
# FIGlet for Go # Motd generator using FIGlet
[![Go Report Card](https://goreportcard.com/badge/github.com/mbndr/figlet4go)](https://goreportcard.com/report/github.com/mbndr/figlet4go) [![Go Report Card](https://goreportcard.com/badge/github.com/kevinmidboe/motdGO)](https://goreportcard.com/report/github.com/kevinmidboe/motdGO)
`figlet4go` is a go library which is a port of [FIGlet](http://www.figlet.org/) to Golang. `motdGO` is a library based on [figlet4go](https://github.com/mbndr/figlet4go) which is a go library which is a port of [FIGlet](http://www.figlet.org/) to Golang.
With `figlet4go` it's easy to create **ascii text banners** in the command-line or with the given api. With `motdGO` it's easy to create **ascii text banners for motd** in the command-line or with the given api.
![screenshot](./screenshot/figlet4go.png) ![screenshot](./screenshot/motdGO.png)
## Build locally
This Repository used to be a fork of [getwe/figlet4go](https://github.com/getwe/figlet4go), but I changed so much that it's not compatible anymore Initialize project:
```bash
## Installation make init
``` ```
$ go get -u github.com/mbndr/figlet4go/...
Install dependencies:
```bash
make install
``` ```
## Usage ## Usage
### Binary from web
Download and run binary:
```bash
wget 'https://raw.githubusercontent.com/kevinmidboe/motdGO/main/motd'
./motd -str 'hello world'
```
### Command-line from source
Run using `go run` from source code:
```bash
go run cmd/motdGO/main.go -str 'hello world'
```
### Command-line ### Command-line
You can use the `figlet4go` command in the command-line. You can use the `motdGO` command in the command-line.
For example (generates the banner on top): For example (generates the banner on top):
```bash ```bash
$ figlet4go -str "figlet4go" -font "larry3d" -colors "green;FF9900;cyan" $ motdGO -str "hello world" -font "larry3d" -colors "green;FF9900;cyan"
``` ```
For a usage instruction read the commands usage with `figlet4go -h`. For a usage instruction read the commands usage with `motdGO -h`.
### Basic ### Basic
You have to create a renderer (`ascii`) and let it render the desired string through the `Render` method. After that you can simply print the returned string. You have to create a renderer (`ascii`) and let it render the desired string through the `Render` method. After that you can simply print the returned string.
```go ```go
import "github.com/mbndr/figlet4go" import "github.com/kevinmidboe/motdGO"
// ... // ...
ascii := figlet4go.NewAsciiRender() ascii := motdGO.NewAsciiRender()
// The underscore would be an error // The underscore would be an error
renderStr, _ := ascii.Render("Hello World") renderStr, _ := ascii.Render("Hello World")
@@ -41,27 +59,27 @@ fmt.Print(renderStr)
``` ```
### Colored ### Colored
The colors given in the `[]figlet4go.Color` slice are repeating if the string is longer than the slice. You have to call the `RenderOpts` instead of the `Render` method to give the Renderer the Options. The colors given in the `[]motdGO.Color` slice are repeating if the string is longer than the slice. You have to call the `RenderOpts` instead of the `Render` method to give the Renderer the Options.
If you use a `TrueColor` color, you have to ensure that your [terminal supports](https://gist.github.com/XVilka/8346728/) it. If you use a `TrueColor` color, you have to ensure that your [terminal supports](https://gist.github.com/XVilka/8346728/) it.
If you use a `AnsiColor` with an `TrueColor` only parser (f.e. `ParserHTML`), `TrueColor` objects are automatically generated. If you use a `AnsiColor` with an `TrueColor` only parser (f.e. `ParserHTML`), `TrueColor` objects are automatically generated.
```go ```go
import "github.com/mbndr/figlet4go" import "github.com/kevinmidboe/motdGO"
// ... // ...
ascii := figlet4go.NewAsciiRender() ascii := motdGO.NewAsciiRender()
// Adding the colors to RenderOptions // Adding the colors to RenderOptions
options := figlet4go.NewRenderOptions() options := motdGO.NewRenderOptions()
options.FontColor = []figlet4go.Color{ options.FontColor = []motdGO.Color{
// Colors can be given by default ansi color codes... // Colors can be given by default ansi color codes...
figlet4go.ColorGreen, motdGO.ColorGreen,
figlet4go.ColorYellow, motdGO.ColorYellow,
figlet4go.ColorCyan, motdGO.ColorCyan,
// ...or by an hex string... // ...or by an hex string...
figlet4go.NewTrueColorFromHexString("885DBA"), motdGO.NewTrueColorFromHexString("885DBA"),
// ...or by an TrueColor object with rgb values // ...or by an TrueColor object with rgb values
figlet4go.TrueColor{136, 93, 186}, motdGO.TrueColor{136, 93, 186},
} }
renderStr, _ := ascii.RenderOpts("Hello Colors", options) renderStr, _ := ascii.RenderOpts("Hello Colors", options)
@@ -72,13 +90,13 @@ fmt.Print(renderStr)
If you want to use another font, you have to specify the name of the font as in this example. If you want to use another font, you have to specify the name of the font as in this example.
Is the font you want to use not [included](#builtin) you have to load the font manually with the `LoadFont` method. This method will walk the path recursively and load all `.flf` files. Is the font you want to use not [included](#builtin) you have to load the font manually with the `LoadFont` method. This method will walk the path recursively and load all `.flf` files.
```go ```go
import "github.com/mbndr/figlet4go" import "github.com/kevinmidboe/motdGO"
// ... // ...
ascii := figlet4go.NewAsciiRender() ascii := motdGO.NewAsciiRender()
options := figlet4go.NewRenderOptions() options := motdGO.NewRenderOptions()
options.FontName = "larry3d" options.FontName = "larry3d"
// If 'larry3d' wouldn't be included you would have to load your .flf files like that: // If 'larry3d' wouldn't be included you would have to load your .flf files like that:
@@ -91,14 +109,14 @@ fmt.Print(renderStr)
### Other parser ### Other parser
A Parser can be set through the `GetParser` function with a valid key A Parser can be set through the `GetParser` function with a valid key
```go ```go
import "github.com/mbndr/figlet4go" import "github.com/kevinmidboe/motdGO"
// ... // ...
ascii := figlet4go.NewAsciiRender() ascii := motdGO.NewAsciiRender()
options := figlet4go.NewRenderOptions() options := motdGO.NewRenderOptions()
p, _ := figlet4go.GetParser("html") p, _ := motdGO.GetParser("html")
options.Parser = *p options.Parser = *p
renderStr, _ := ascii.RenderOpts("Hello Fonts", options) renderStr, _ := ascii.RenderOpts("Hello Fonts", options)
@@ -128,17 +146,3 @@ The default font is `standard`. These are the builtin fonts:
### Other fonts ### Other fonts
Other fonts can mainly be found on [figlet](http://www.figlet.org). You have to load them as in [this example](#other-font). Other fonts can mainly be found on [figlet](http://www.figlet.org). You have to load them as in [this example](#other-font).
## Todo
- [ ] Tests
- [ ] automatically the perfect char margin
- [ ] Linebreak possible?
- [ ] Pointer-Value standarization
- [ ] Parser as interface
- [x] Cli client
- [x] Colors in the cli client
- [x] No dependencies (fatih/color)
- [x] Truecolor support
- [x] More parsers (HTML)
- [x] Better parsers (maybe stored in a map)
- [x] Writer choosing for writing to file