Skip to content

Commit ffce8a0

Browse files
committed
Revert "add name command closes #8"
The commit helped me realize that it makes more sense for the library to feature an additional map from emoji character to emoji rather than a new function which outputs a single struct field. This reverts commit 56d8bcb.
1 parent 56d8bcb commit ffce8a0

File tree

8 files changed

+1
-168
lines changed

8 files changed

+1
-168
lines changed

README.md

-34
Original file line numberDiff line numberDiff line change
@@ -61,40 +61,6 @@ Char: 🐢
6161
Category: "animals_and_nature"
6262
Keywords: ["animal" "slow" "nature" "tortoise"]
6363
```
64-
### Name
65-
66-
Use ``Name()`` to find the name of an emojis.
67-
68-
```go
69-
package main
70-
71-
import (
72-
"fmt"
73-
"os"
74-
75-
"github.com/hackebrot/turtle"
76-
)
77-
78-
func main() {
79-
n := "👺"
80-
emoji := turtle.Name(n)
81-
82-
if emoji == nil {
83-
fmt.Fprintf(os.Stderr, "no name found for search: %v\n", n)
84-
os.Exit(1)
85-
}
86-
87-
fmt.Printf("Name: %q\n", emoji.Name)
88-
fmt.Printf("Char: %s\n", emoji.Char)
89-
fmt.Printf("Category: %q\n", emoji.Category)
90-
fmt.Printf("Keywords: %q\n", emoji.Keywords)
91-
}
92-
```
93-
94-
```text
95-
japanese_goblin
96-
```
97-
9864

9965
### Search
10066

cmd/turtle/README.md

-11
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ Available Commands:
1919
category Print all emojis of the category
2020
help Help about any command
2121
keyword Print all emojis with the keyword
22-
name Print the name of an emoji
2322
list Print a list of values from the turtle library
2423
search Print emojis with a name that contains the search string
2524
version Print the version number of turtle
@@ -138,16 +137,6 @@ turtle -i " " category travel_and_places
138137
]
139138
```
140139

141-
### Name
142-
143-
```bash
144-
$ turtle name 👚
145-
```
146-
147-
```
148-
womans_clothes
149-
```
150-
151140
### Keyword
152141

153142
```bash

cmd/turtle/name.go

-42
This file was deleted.

cmd/turtle/name_test.go

-32
This file was deleted.

cmd/turtle/turtle.go

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ var (
2929
func init() {
3030
cmdTurtle.AddCommand(cmdCategory)
3131
cmdTurtle.AddCommand(cmdKeyword)
32-
cmdTurtle.AddCommand(cmdName)
3332
cmdTurtle.AddCommand(cmdSearch)
3433
cmdTurtle.AddCommand(cmdVersion)
3534
cmdTurtle.AddCommand(cmdList)

filters.go

-11
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,6 @@ func category(emojis []*Emoji, c string) []*Emoji {
2020
})
2121
}
2222

23-
// name returns the name based on emoji
24-
func name(emojis []*Emoji, n string) *Emoji {
25-
results := filter(emojis, func(e *Emoji) bool {
26-
return e.Char == n
27-
})
28-
if len(results) > 0 {
29-
return results[0]
30-
}
31-
return nil
32-
}
33-
3423
// keyword filters a slice of Emoji by Keywords
3524
func keyword(emojis []*Emoji, k string) []*Emoji {
3625
return filter(emojis, func(e *Emoji) bool {

turtle.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package turtle
22

33
// Version of the turtle library
4-
const Version = "v0.1.1"
4+
const Version = "v0.1.0"
55

66
// Emojis maps a name to an Emoji
77
var Emojis = make(map[string]*Emoji)
@@ -17,11 +17,6 @@ func Search(s string) []*Emoji {
1717
return search(emojis, s)
1818
}
1919

20-
// Name retuns the emoji for a given name
21-
func Name(n string) *Emoji {
22-
return name(emojis, n)
23-
}
24-
2520
// Keyword filters the emojis by a keyword
2621
func Keyword(k string) []*Emoji {
2722
return keyword(emojis, k)

turtle_test.go

-31
Original file line numberDiff line numberDiff line change
@@ -74,37 +74,6 @@ func Test_category(t *testing.T) {
7474
}
7575
}
7676

77-
func Test_name(t *testing.T) {
78-
tests := []struct {
79-
name string
80-
char string
81-
want *Emoji
82-
}{
83-
{
84-
name: "no matches",
85-
char: "",
86-
want: nil,
87-
},
88-
{
89-
name: "single match",
90-
char: "☕",
91-
want: &Emoji{
92-
Name: "coffee",
93-
Category: "food_and_drink",
94-
Char: "☕",
95-
Keywords: []string{"beverage", "caffeine", "latte", "espresso"},
96-
},
97-
},
98-
}
99-
for _, tt := range tests {
100-
t.Run(tt.name, func(t *testing.T) {
101-
if got := name(testEmojis, tt.char); !cmp.Equal(got, tt.want) {
102-
t.Errorf("name() = %v, want %v", repr.Repr(got), repr.Repr(tt.want))
103-
}
104-
})
105-
}
106-
}
107-
10877
func Test_keyword(t *testing.T) {
10978
tests := []struct {
11079
name string

0 commit comments

Comments
 (0)