mirror of
https://github.com/bdnugget/eggos.git
synced 2026-11-07 04:17:27 +00:00
Add Cowsay App (#89)
This commit is contained in:
9 files changed
+216
No files matched your search
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @version:
|
||||
* @Author: cm.d
|
||||
* @Date: 2021-11-07 00:01:19
|
||||
* @LastEditors: cm.d
|
||||
* @LastEditTime: 2021-11-07 00:56:32
|
||||
*/
|
||||
package animal
|
||||
|
||||
type CowTemplate struct {
|
||||
}
|
||||
|
||||
func (cowTemplate CowTemplate) Get() string {
|
||||
cowTempalte := `
|
||||
\ ^__^
|
||||
\ (oo)\_______
|
||||
(__)\ )\/\
|
||||
||----w |
|
||||
|| ||
|
||||
`
|
||||
return cowTempalte
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @version:
|
||||
* @Author: cm.d
|
||||
* @Date: 2021-11-07 15:00:52
|
||||
* @LastEditors: cm.d
|
||||
* @LastEditTime: 2021-11-07 15:37:45
|
||||
*/
|
||||
|
||||
package animal
|
||||
|
||||
type DemonTemplate struct {
|
||||
}
|
||||
|
||||
func (dt DemonTemplate) Get() string {
|
||||
demonTemplate := `
|
||||
\ , ,
|
||||
\ /( )'
|
||||
\ \\ \\___ / |
|
||||
/- _ '-/ '
|
||||
(/\\/ \\ \\ /\\
|
||||
/ / | ' \
|
||||
O O ) / |
|
||||
'-^--''< '
|
||||
(_.) _ ) /
|
||||
'.___/' /
|
||||
'-----' /
|
||||
<----. __ / __ \\
|
||||
<----|====O)))==) \\) /====
|
||||
<----' '--' '.__,' \\
|
||||
| |
|
||||
\\ /
|
||||
______( (_ / \\______
|
||||
,' ,-----' | \\
|
||||
'--{__________) \\
|
||||
`
|
||||
return demonTemplate
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @version:
|
||||
* @Author: cm.d
|
||||
* @Date: 2021-11-07 15:00:52
|
||||
* @LastEditors: cm.d
|
||||
* @LastEditTime: 2021-11-07 15:15:46
|
||||
*/
|
||||
|
||||
package animal
|
||||
|
||||
type MonkeyTemplate struct {
|
||||
}
|
||||
|
||||
func (mt MonkeyTemplate) Get() string {
|
||||
monkeyTemplate := `
|
||||
\
|
||||
\
|
||||
\
|
||||
.="=.
|
||||
_/.-.-.\_ _
|
||||
( ( o o ) ) ))
|
||||
|/ " \| //
|
||||
\'---'/ //
|
||||
/'"""'\\ ((
|
||||
/ /_,_\ \\ \\
|
||||
\_\_'__/ \ ))
|
||||
/' /'~\ |//
|
||||
/ / \ /
|
||||
,--',--'\/\ /
|
||||
'-- "--' '--'
|
||||
`
|
||||
return monkeyTemplate
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @version:
|
||||
* @Author: cm.d
|
||||
* @Date: 2021-11-07 15:04:45
|
||||
* @LastEditors: cm.d
|
||||
* @LastEditTime: 2021-11-07 15:15:02
|
||||
*/
|
||||
package animal
|
||||
|
||||
type PigTemplate struct {
|
||||
}
|
||||
|
||||
func (pt PigTemplate) Get() string {
|
||||
pigTemplate := `
|
||||
\
|
||||
\
|
||||
_//| .-~~~-.
|
||||
_/oo } }-@
|
||||
('')_ } |
|
||||
'--'| { }--{ }
|
||||
//_/ /_/
|
||||
`
|
||||
return pigTemplate
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @version:
|
||||
* @Author: cm.d
|
||||
* @Date: 2021-11-07 02:52:15
|
||||
* @LastEditors: cm.d
|
||||
* @LastEditTime: 2021-11-07 02:55:45
|
||||
*/
|
||||
package animal
|
||||
|
||||
type SheepTemplate struct {
|
||||
}
|
||||
|
||||
func (st SheepTemplate) Get() string {
|
||||
sheepTemplate := `
|
||||
\
|
||||
\ __
|
||||
UooU\.'@@@@@@'.
|
||||
\__/(@@@@@@@@@@)
|
||||
(@@@@@@@@)
|
||||
'YY~~~~YY'
|
||||
|| ||
|
||||
`
|
||||
return sheepTemplate
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* @Descripttion:cowsay
|
||||
* @version:
|
||||
* @Author: cm.d
|
||||
* @Date: 2021-11-06 19:49:21
|
||||
* @LastEditors: cm.d
|
||||
* @LastEditTime: 2021-11-07 15:28:01
|
||||
*/
|
||||
|
||||
package cowsay
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/dj456119/go-cowsay/gocowsay"
|
||||
|
||||
"github.com/icexin/eggos/app"
|
||||
"github.com/icexin/eggos/app/cowsay/animal"
|
||||
)
|
||||
|
||||
var animalTempalteMap = make(map[string]AnimalTemplate)
|
||||
|
||||
type AnimalTemplate interface {
|
||||
Get() string
|
||||
}
|
||||
|
||||
func cowsay(ctx *app.Context) error {
|
||||
err := ctx.ParseFlags()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if ctx.Flag().NArg() == 0 {
|
||||
return errors.New("no input")
|
||||
}
|
||||
info := ctx.Flag().Arg(0)
|
||||
animal := ctx.Flag().Arg(1)
|
||||
animalTemplate, err := GetAnimal(animal)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Print(gocowsay.Format(animalTemplate.Get(), info))
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetAnimal(animalType string) (AnimalTemplate, error) {
|
||||
if animalTemplate, ok := animalTempalteMap[animalType]; !ok {
|
||||
return nil, errors.New("no support animal " + animalType)
|
||||
} else {
|
||||
return animalTemplate, nil
|
||||
}
|
||||
}
|
||||
|
||||
func RegisterAnimalTemplate(animalType string, animalTemplate AnimalTemplate) {
|
||||
animalTempalteMap[animalType] = animalTemplate
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterAnimalTemplate("", animal.CowTemplate{})
|
||||
RegisterAnimalTemplate("cow", animal.CowTemplate{})
|
||||
RegisterAnimalTemplate("sheep", animal.SheepTemplate{})
|
||||
RegisterAnimalTemplate("demon", animal.DemonTemplate{})
|
||||
RegisterAnimalTemplate("pig", animal.PigTemplate{})
|
||||
RegisterAnimalTemplate("monkey", animal.MonkeyTemplate{})
|
||||
app.Register("cowsay", cowsay)
|
||||
}
|
||||
@@ -4,6 +4,7 @@ go 1.16
|
||||
|
||||
require (
|
||||
github.com/aarzilli/nucular v0.0.0-20210408133902-d3dd7b05a80a
|
||||
github.com/dj456119/go-cowsay v0.0.5
|
||||
github.com/fogleman/fauxgl v0.0.0-20200818143847-27cddc103802
|
||||
github.com/fogleman/gg v1.3.0
|
||||
github.com/fogleman/nes v0.0.0-20210605215016-0aace4b1814a
|
||||
|
||||
@@ -198,6 +198,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
||||
github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/dj456119/go-cowsay v0.0.5 h1:TDds6iF42JDU6vHhsOY/8uWaYv6eCn/EcEyoP1QrzYg=
|
||||
github.com/dj456119/go-cowsay v0.0.5/go.mod h1:jTKj4Qsp7pyL4L5/nE9F6yNz1+6SerXzgBeadZvmA2c=
|
||||
github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E=
|
||||
github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||
github.com/docker/docker v1.4.2-0.20191028175130-9e7d5ac5ea55/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
|
||||
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
_ "github.com/icexin/eggos/app/cmd"
|
||||
// _ "github.com/icexin/eggos/app/gin"
|
||||
_ "github.com/icexin/eggos/app/cowsay"
|
||||
_ "github.com/icexin/eggos/app/httpd"
|
||||
_ "github.com/icexin/eggos/app/js"
|
||||
_ "github.com/icexin/eggos/app/phy"
|
||||
|
||||
Reference in new issue
Block a user