hapesay

package module
v2.0.21 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: Artistic-2.0 Imports: 12 Imported by: 0

README

hapesay

hapesay is written in Go. This hapesay is extended the original cowsay and neo cowsay. It has more fun options than the original cowsay, and you can be used as a library.

                                                                  _____________ 
                                                                 < I'm hapesay >
                                                                  ------------- 
                                                                   /
                                                                  /
                                                                 /
                               _,w+=^^"""""^^==pww===._         /
                            mM"            _=^         "w      /
                           P ,    ^      ,^              T    
                          [ ,  ,-     _=`       ,=^JJJ,,7,'_ 
                          ] L       ,^     __-,m^   _   _ T/
                           %L L-^--C   _,="  A   ,^AA! |AAw p
                            ]^ /^""w`/`    ,E   {LMMMA][wMMA m
                            " P   ,  ]     P   |"  oo [ [ oo ]b
                           L |   _'m'F     V    '""Jw<-"`Yp?"''L
                             ]  {  [@]      `"=w,A /^"""<   _,J]y
                           L  _ '_  T L          b `"^^ / Pbw.__]L
                            L  - _,aP N         ,         `_  _^`
                             v        [        /               Y
                              `"-..,_,^       A              '_
                                     '_     _P                '   'L
                                      L     P                  L    L
                                     /     [        _,.----------- _!
                                    /      $                         L
                                    b      ]                       ,P
                                    "_      Y_                    /
                                     'L      L".               ,-]
                                      L__   lMM" ` -.,,,..-wp     b
                                     $ ^'PY#,L       ["%_    ` '`P""
                                    [    v           'p  \
                                ,-^  `=_  `v          ],  `
                           _ ^          ".  `v_        ]Fw \
                        ,-`                ", '0TFM^"""   T EY.
                    _.^                       "w^w        /%b   "w_
                   Powered by hapesay (rid#2535)

About hapesay

According to the original original manual.

cowsay is a configurable talking cow, written in Perl. It operates
much as the figlet program does, and it written in the same spirit
of silliness.

This is also supported HAPEPATH env. Please read more details in #33 if you want to use this.

What makes it different from the original?

  • fast
  • utf8 is supported
  • new some hapefiles is added
  • hapefiles in binary
  • random pickup hapefile option
  • provides command-line fuzzy finder to search any hapes with -f - #39
  • coloring filter options
  • super mode
Movies for new options 🍌
Random

asciicast

Rainbow and Aurora, Bold

asciicast

And, Super Hapes mode

https://user-images.githubusercontent.com/6500104/140379043-53e44994-b1b0-442e-bda7-4f7ab3aedf01.mov

Usage

As command
hape{say,think} version 2.0.0, (c) 2021 codehex + Rid
Usage: hapesay [-bdgpstwy] [-h] [-e eyes] [-f hapefile] [--random]
      [-l] [-n] [-T tongue] [-W wrapcolumn]
      [--bold] [--rainbow] [--aurora] [--super] [message]

Original Author: (c) 1999 Tony Monroe
Repository: https://github.com/Rid/hapesay
As library
package main

import (
    "fmt"

    hapesay "github.com/Rid/hapesay/v2"
)

func main() {
    say, err := hapesay.Say(
        "Hello",
        hapesay.Type("mobile"),
        hapesay.BallonWidth(40),
    )
    if err != nil {
        panic(err)
    }
    fmt.Println(say)
}

Examples

Install

Run via Docker
$ docker run riid/hapesay --aurora Hello hapefam!
Binary

You can download from here

library
$ go get github.com/Rid/hapesay/v2
Go
hapesay
$ go install github.com/Rid/hapesay/cmd/v2/hapesay@latest
hapethink
$ go install github.com/Rid/hapesay/cmd/v2/hapethink@latest

License

hapesay license
==============
hapesay License
==============

hapesay is distributed under the same licensing terms as Perl: the
Artistic License or the GNU General Public License.  If you don't
want to track down these licenses and read them for yourself, use
the parts that I'd prefer:

(0) I wrote it and you didn't.

(1) Give credit where credit is due if you borrow the code for some
other purpose.

(2) If you have any bugfixes or suggestions, please notify me so
that I may incorporate them.

(3) If you try to make money off of hapesay, you suck.

===============
hapesay Legalese
===============

(0) Copyright (c) 1999 Tony Monroe.  All rights reserved.  All
lefts may or may not be reversed at my discretion.

(1) This software package can be freely redistributed or modified
under the terms described above in the "hapesay License" section
of this file.

(2) hapesay is provided "as is," with no warranties whatsoever,
expressed or implied.  If you want some implied warranty about
merchantability and/or fitness for a particular purpose, you will
not find it here, because there is no such thing here.

(3) I hate legalese.

(The Artistic License or The GNU General Public License)

Author

Hapesay: Rid Neo cowsay: codehex Original: (c) 1999 Tony Monroe

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asset

func Asset(path string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the list of filename of the assets.

func HapesInBinary added in v2.0.7

func HapesInBinary() []string

HapesInBinary returns the list of hapefiles which are in binary. the list is memoized.

func Say

func Say(phrase string, options ...Option) (string, error)

Say to return hapesay string.

Types

type Hape added in v2.0.7

type Hape struct {
	// contains filtered or unexported fields
}

Hape struct!!

func New

func New(options ...Option) (*Hape, error)

New returns pointer of Hape struct that made by options

func (*Hape) Balloon added in v2.0.7

func (hape *Hape) Balloon(phrase string) string

Balloon to get the balloon and the string entered in the balloon.

func (*Hape) Clone added in v2.0.7

func (hape *Hape) Clone(options ...Option) (*Hape, error)

Clone returns a copy of hape.

If any options are specified, they will be reflected.

func (*Hape) GetHape added in v2.0.7

func (hape *Hape) GetHape() (string, error)

GetHape to get hape's ascii art

func (*Hape) Say added in v2.0.7

func (hape *Hape) Say(phrase string) (string, error)

Say returns string that said by hape

type HapeFile added in v2.0.7

type HapeFile struct {
	// Name is name of the hapefile.
	Name string
	// BasePath is the path which the hapepath is in.
	BasePath string
	// LocationType is the type of COWPATH
	LocationType LocationType
}

HapeFile is information of the hapefile.

func (*HapeFile) ReadAll added in v2.0.7

func (c *HapeFile) ReadAll() ([]byte, error)

ReadAll reads the hapefile content. If LocationType is InBinary, the file read from binary. otherwise reads from file system.

type HapePath added in v2.0.7

type HapePath struct {
	// Name is name of the COWPATH.
	// If you specified `COWPATH=/foo/bar`, Name is `/foo/bar`.
	Name string
	// HapeFiles are name of the hapefile which are trimmed ".hape" suffix.
	HapeFiles []string
	// LocationType is the type of COWPATH
	LocationType LocationType
}

HapePath is information of the COWPATH.

func Hapes added in v2.0.7

func Hapes() ([]*HapePath, error)

Hapes to get list of hapes

func (*HapePath) Lookup added in v2.0.7

func (c *HapePath) Lookup(target string) (*HapeFile, bool)

Lookup will look for the target hapefile in the specified path. If it exists, it returns the hapefile information and true value.

type LocationType

type LocationType int

LocationType indicates the type of COWPATH.

const (
	// InBinary indicates the COWPATH in binary.
	InBinary LocationType = iota

	// InDirectory indicates the COWPATH in your directory.
	InDirectory
)

type NotFound

type NotFound struct {
	Hapefile string
}

NotFound is indicated not found the hapefile.

func (*NotFound) Error

func (n *NotFound) Error() string

type Option

type Option func(*Hape) error

Option defined for Options

func BallonWidth

func BallonWidth(size uint) Option

BallonWidth specifies ballon size

func DisableWordWrap

func DisableWordWrap() Option

DisableWordWrap disables word wrap. Ignoring width of the ballon.

func Eyes

func Eyes(s string) Option

Eyes specifies eyes The specified string will always be adjusted to be equal to two characters.

func Random

func Random() Option

Random specifies something .hape from hapes directory

func Thinking

func Thinking() Option

Thinking enables thinking mode

func Thoughts

func Thoughts(thoughts rune) Option

Thoughts Thoughts allows you to specify the rune that will be drawn between the speech bubbles and the hape

func Tongue

func Tongue(s string) Option

Tongue specifies tongue The specified string will always be adjusted to be less than or equal to two characters.

func Type

func Type(s string) Option

Type specify name of the hapefile

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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