Skip to content

Commit

Permalink
Improve usage and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
bcongdon committed Nov 12, 2018
1 parent e8e15b3 commit 18bb667
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,23 @@ go install github.com/bcongdon/ep
## Usage

```
ep
Usage of ./ep:
./ep [QUERY]
-noninteractive
If set, doesn't display emoji picker -- instead just outputting the first selection for the provided query.
-output string
The output of ep. Choices: clipboard, stdout (default "clipboard")
```

Navigation can be done with the arrow keys. Pressing `Enter` copies the selected emoji to the clipboard.

### Examples

- `ep` - Opens the default emoji picker.
- `ep wink` - Opens the default emoji picker with the query "wink" already entered
- `ep -noninteractive wink` - Copies the first search result for "wink" to the clipboard
- `ep -noninteractive -output=stdout wink` - Outputs the first search result for "wink" to stdout

## Troubleshooting

- If you see blank squares in the emoji grid, these emojis cannot be rendered by your terminal's font.
Expand Down
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"flag"
"fmt"
"log"
"os"
"sort"
"strings"

Expand All @@ -20,6 +21,12 @@ const numCols int = 10
var outputFlag = flag.String("output", "clipboard", "The output of ep. Choices: clipboard, stdout")
var noninteractiveFlag = flag.Bool("noninteractive", false, "If set, doesn't display emoji picker -- instead just outputting the first selection for the provided query.")

var usageFunc = func() {
fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s:\n", os.Args[0])
fmt.Fprintf(flag.CommandLine.Output(), "%s [QUERY]\n", os.Args[0])
flag.PrintDefaults()
}

type Emoji struct {
Keywords []string `json:"keywords"`
Char string `json:"char"`
Expand Down Expand Up @@ -107,6 +114,7 @@ func runNoninterativeMode(emojis map[string][]Emoji, query string) {
}

func main() {
flag.Usage = usageFunc
flag.Parse()
validateFlags()

Expand Down

0 comments on commit 18bb667

Please sign in to comment.