Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
7bf70a9dc6 | |||
72af16723b | |||
6a152aa6b4 | |||
6b3b39ad40 | |||
59c12cb89b |
11
README.md
Normal file
11
README.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# emt
|
||||||
|
CLI Emojis
|
||||||
|
|
||||||
|
Binaries:
|
||||||
|
https://bullercodeworks.com/downloads/emt/
|
||||||
|
|
||||||
|
Included is a completion script for bash:
|
||||||
|
* `emt-completion.bash`
|
||||||
|
|
||||||
|
Just put `emt` in your path, then source the completion script when you
|
||||||
|
fire up your shell (put a line in your bashrc or something)
|
3
emt-completion.bash
Normal file
3
emt-completion.bash
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#/usr/bin/env bash
|
||||||
|
WORDLIST=`emt -completion-list`
|
||||||
|
complete -W "$WORDLIST" emt
|
5
go.mod
Normal file
5
go.mod
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module git.bullercodeworks.com/brian/emt
|
||||||
|
|
||||||
|
go 1.16
|
||||||
|
|
||||||
|
require github.com/kyokomi/emoji v2.2.4+incompatible
|
2
go.sum
Normal file
2
go.sum
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
github.com/kyokomi/emoji v2.2.4+incompatible h1:np0woGKwx9LiHAQmwZx79Oc0rHpNw3o+3evou4BEPv4=
|
||||||
|
github.com/kyokomi/emoji v2.2.4+incompatible/go.mod h1:mZ6aGCD7yk8j6QY6KICwnZ2pxoszVseX1DNoGtU2tBA=
|
98
main.go
98
main.go
@ -8,80 +8,48 @@ import (
|
|||||||
"github.com/kyokomi/emoji"
|
"github.com/kyokomi/emoji"
|
||||||
)
|
)
|
||||||
|
|
||||||
var emoticons map[string]string
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
initEmoticons()
|
if len(os.Args) < 2 || strings.HasSuffix(os.Args[1], "-help") {
|
||||||
// We default to "shrug"
|
showUsage()
|
||||||
var done bool
|
}
|
||||||
|
|
||||||
|
var getApprox bool
|
||||||
var which string
|
var which string
|
||||||
if len(os.Args) == 2 {
|
var matchWhich string
|
||||||
which = os.Args[1]
|
allEmoji := emoji.CodeMap()
|
||||||
if which == "help" {
|
for _, v := range os.Args {
|
||||||
showHelp()
|
if v == "-a" {
|
||||||
} else if which == "help-emoji" {
|
getApprox = true
|
||||||
allEmoji := emoji.CodeMap()
|
} else if v == "-completion-list" {
|
||||||
fmt.Println("== Supported Emoji ==")
|
for k := range allEmoji {
|
||||||
for k, v := range allEmoji {
|
fmt.Print(strings.Trim(k, ":"), " ")
|
||||||
fmt.Println(k + " " + v)
|
|
||||||
}
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
// it might be a one-word emoji request
|
|
||||||
allEmoji := emoji.CodeMap()
|
|
||||||
if _, done = allEmoji[which]; done {
|
|
||||||
tst1 := ":" + which + ":"
|
|
||||||
tst2 := emoji.Sprint(tst1)
|
|
||||||
if tst1 != tst2 {
|
|
||||||
fmt.Println(tst2)
|
|
||||||
done = true
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Search for any emoji that contain this string
|
which = v
|
||||||
var cnt int
|
}
|
||||||
for k, v := range allEmoji {
|
}
|
||||||
if strings.Contains(k, which) {
|
|
||||||
fmt.Println(k + " " + v)
|
if !strings.HasPrefix(which, ":") && !strings.HasSuffix(which, ":") {
|
||||||
cnt++
|
matchWhich = ":" + which + ":"
|
||||||
}
|
}
|
||||||
}
|
if v, ok := allEmoji[matchWhich]; ok {
|
||||||
if cnt > 0 {
|
fmt.Println(v)
|
||||||
done = true
|
os.Exit(0)
|
||||||
} else {
|
} else if getApprox {
|
||||||
fmt.Println("No emoji for " + which + " found.")
|
for k, v := range allEmoji {
|
||||||
|
if strings.Contains(k, which) {
|
||||||
|
fmt.Println(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !done {
|
os.Exit(1)
|
||||||
var i string
|
|
||||||
if i, done = emoticons[which]; done {
|
|
||||||
fmt.Println(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !done {
|
|
||||||
showHelp()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func showHelp() {
|
func showUsage() {
|
||||||
fmt.Println("There are a *ton* of emoji supported, to list them, do \"help-emoji\"")
|
allEmoji := emoji.CodeMap()
|
||||||
for k, v := range emoticons {
|
fmt.Println("== Supported Emoji ==")
|
||||||
fmt.Println(k, v)
|
for k, v := range allEmoji {
|
||||||
|
fmt.Println(k + " " + v)
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initEmoticons() {
|
|
||||||
emoticons = make(map[string]string)
|
|
||||||
emoticons["ascii-bat"] = "~°·_·°~"
|
|
||||||
emoticons["ascii-bomb"] = "●~*"
|
|
||||||
emoticons["ascii-fish"] = ">°)))彡"
|
|
||||||
emoticons["ascii-flip"] = "(╯°□°)╯︵ ┻━┻"
|
|
||||||
emoticons["ascii-lenny"] = "( ͡° ͜ʖ ͡°)"
|
|
||||||
emoticons["ascii-octopus"] = "<コ:彡"
|
|
||||||
emoticons["ascii-shrug"] = "¯\\_(ツ)_/¯"
|
|
||||||
emoticons["ascii-smirk"] = "( ͡° ͜ʖ ͡°)"
|
|
||||||
emoticons["ascii-snake"] = "~>°)~~~"
|
|
||||||
emoticons["ascii-star"] = "☆彡"
|
|
||||||
emoticons["ascii-tadpole"] = "(°°)~"
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user