libgosay

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2020 License: MIT Imports: 4 Imported by: 0

README

Lib Go Say

Cowsay reimplementation in Go lib !

Go Report Card shield.io-coverage

One day, i noticed that there no lib to easy use CowSay with Go. So i made it :D

Gopher Say with libgosay

GopherSay

How to using it

First, use Create() to instance and init a Pimp struct
Now you can config you gosay instance like you whant
When your configuration are done, you can use Say() to build a string formated like Cowsay

Simple exemple

package main

inport (
    "fmt"
    "git.iglou.eu/Production/libgosay"
)

func main() {
    // Instance and init gosay Pimp struc
    gosay := libgosay.Create()
    // Catch say result
    say, err := gosay.Say("Heya, it's me Imoen")
    if err != nil {
        // do some thing ...
    }

    fmt.Println(say)
}

Cool Features

Some features are the same of Cowsay, but with little more.

  • Max Rune by line
  • Show body only without any bubble
  • Can pimp your Bubble
  • Can pimp Tail Eye Tongue
  • Load custom ASCII Body (with Pimp.Body = body string)

Ex:

Pimp.Eye = "O"
Pimp.Tongue = "VV"
Pimp.Tail = "o"

Give us:

 _____________________ 
< Heya, it's me Imoen >
 --------------------- 
    o   ˏ⋒___⋒ˎ
     o  ▏ O__O ▕
        ▏  VV  ▕
        ▏U    U▕
        ▏      ▕
        ˋ-U---U-ˊ

Pimp your bubble

By default, the traditionnal 'say' bubble are used

 ________
< A word >
 --------

 _____________________
/ Multiple line       \
| message exemple     |
\ for my BFF Imoen... /
 ---------------------

But you can using some other presconfigured Bubble

  • Think()
  • Whisper()
  • Narrative()

like this:

gosay := libgosay.Pimp
gosay.Bubble.Whisper()

And, you can also setting it manually

OneLine config is used instead of FirstLine, Lines and LastLine
Only if the string you want to say, is not bigger then one line.

  • Each config line use 3 Rune
  • First rune are for the Left side
  • Second rune is repeated X.time (string len)
  • Third rune are for the Right side
gosay := libgosay.Pimp

// Eatch 
gosay.Bubble.Before = [3]rune{'', '', ''}
gosay.Bubble.OneLine = [3]rune{'', '', ''}
gosay.Bubble.FirstLine = [3]rune{'', '', ''}
gosay.Bubble.Lines = [3]rune{'', '', ''}
gosay.Bubble.LastLine = [3]rune{'', '', ''}
gosay.Bubble.After = [3]rune{'', '', ''}

Todo

  • Separate Right and Left Eye (Rune table ?)
  • Tail rotation possibility (Text at right or left)

License

 ____________________________________________________________ 
/ This project is licensed under the MIT license.            \
\ The licence file is available on repo LICENSE file         /
 ------------------------------------------------------------ 
        \   ˏ⋒____⋒ˎ
         \  ▏ @__@ ▕
            ▏  UU  ▕
            ▏U    U▕
            ▏      ▕
            ˋ-U--U-ˊ

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BubbleDef

type BubbleDef struct {
	Before    [3]rune
	OneLine   [3]rune
	FirstLine [3]rune
	Lines     [3]rune
	LastLine  [3]rune
	After     [3]rune
}

BubbleDef is for defined the bubble structure That cane be done manually or using a pre configured structure

func (*BubbleDef) Narrative

func (b *BubbleDef) Narrative()

Narrative define a narrative text structure

func (*BubbleDef) Speak

func (b *BubbleDef) Speak()

Speak define a speaking bubble structure

func (*BubbleDef) Think

func (b *BubbleDef) Think()

Think define a thinking bubble structure

func (*BubbleDef) Whisper

func (b *BubbleDef) Whisper()

Whisper define a whisp bubble structure

type Pimp

type Pimp struct {
	Column int
	Said   string

	Body   string
	Eye    string
	Tongue string
	Tail   string

	Bubble BubbleDef
}

Pimp is the main part of this lib You need to instance a Pimp struct for using it

func Create

func Create() Pimp

Create make a Pimp struct, init default values and return it

func (Pimp) Say

func (p Pimp) Say(s string) (string, error)

Say is for say some thing with the lib

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL