Skip to content

Commit

Permalink
Merge pull request #37 from yanosea/6-add-sub-command-history-and-fav…
Browse files Browse the repository at this point in the history
…orite-commands

✨feat: implement commands 'history' and 'favorite'
  • Loading branch information
yanosea authored Oct 7, 2024
2 parents 5a03d3a + ad7ccf4 commit 3dc5370
Show file tree
Hide file tree
Showing 321 changed files with 74,147 additions and 4,674 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ jrp
jrp.exe
.DS_Store
*.log

# NOT IGNORE FOLDER
!jrp/
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ builds:
- darwin
ldflags:
- -s -w
- -X github.com/yanosea/jrp/cmd.version=v{{.Version}}
- -X github.com/yanosea/jrp/cmd.ver=v{{.Version}}

archives:
- format: tar.gz
Expand Down
169 changes: 169 additions & 0 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,61 @@ https://github.com/briandowns/spinner

================================================================

github.com/chzyer/readline
https://github.com/chzyer/readline
----------------------------------------------------------------
The MIT License (MIT)

Copyright (c) 2015 Chzyer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================================

github.com/chzyer/test
https://github.com/chzyer/test
----------------------------------------------------------------
The MIT License (MIT)

Copyright (c) 2016 chzyer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

================================================================

github.com/dustin/go-humanize
https://github.com/dustin/go-humanize
----------------------------------------------------------------
Expand Down Expand Up @@ -1082,6 +1137,41 @@ https://github.com/inconshreveable/mousetrap

================================================================

github.com/manifoldco/promptui
https://github.com/manifoldco/promptui
----------------------------------------------------------------
BSD 3-Clause License

Copyright (c) 2017, Arigato Machine Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

================================================================

github.com/mattn/go-colorable
https://github.com/mattn/go-colorable
----------------------------------------------------------------
Expand Down Expand Up @@ -1124,6 +1214,33 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

================================================================

github.com/mattn/go-runewidth
https://github.com/mattn/go-runewidth
----------------------------------------------------------------
The MIT License (MIT)

Copyright (c) 2016 Yasuhiro Matsumoto

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

================================================================

github.com/ncruces/go-strftime
https://github.com/ncruces/go-strftime
----------------------------------------------------------------
Expand Down Expand Up @@ -1151,6 +1268,31 @@ SOFTWARE.

================================================================

github.com/olekukonko/tablewriter
https://github.com/olekukonko/tablewriter
----------------------------------------------------------------
Copyright (C) 2014 by Oleku Konko

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

================================================================

github.com/pmezard/go-difflib
https://github.com/pmezard/go-difflib
----------------------------------------------------------------
Expand Down Expand Up @@ -1217,6 +1359,33 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

================================================================

github.com/rivo/uniseg
https://github.com/rivo/uniseg
----------------------------------------------------------------
MIT License

Copyright (c) 2019 Oliver Kuederle

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

================================================================

github.com/spf13/cobra
https://github.com/spf13/cobra
----------------------------------------------------------------
Expand Down
96 changes: 80 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
[![Latest Release](https://img.shields.io/github/v/release/yanosea/jrp?style=flat-square)](https://github.com/yanosea/jrp/releases/latest)
<br/>
[Coverage Report](https://yanosea.github.io/jrp/coverage.html)
<br/>
![demo](docs/demo.gif "demo")

</div>

![demo](docs/demo.gif "demo")

## ℹ️ About

`jrp` is the CLI tool to generate Japanese random phrase(s). (It's jokeey tool!)
This tool uses [WordNet Japan](https://bond-lab.github.io/wnja/jpn/downloads.html) sqlite database file.
You can save the generated phrase(s) to the history and manage them.
Also, you can save the generated phrase(s) to the favorite and manage them.

This tool uses [WordNet Japan sqlite database file](https://bond-lab.github.io/wnja/jpn/downloads.html).

## 💻 Usage

Expand All @@ -32,34 +35,56 @@ Usage:
jrp [command]
Available Subcommands:
download, dl, d 📦 Download Japanese Wordnet sqlite3 database file from the official site.
generate, gen, g ✨ Generate Japanese random phrase(s). You can abbreviate "generate" sub command. ("jrp" and "jrp generate" are the same.)
help 🤝 Help of jrp.
completion 🔧 Generate the autocompletion script for the specified shell.
version 🔖 Show the version of jrp.
download, dl, d 📦 Download WordNet Japan sqlite database file from the official web site.
generate, gen, g ✨ Generate Japanese random phrase(s). You can abbreviate "generate" sub command. ("jrp" and "jrp generate" are the same.)
history, hist, h 📜 Manage the history of the "generate" command.
favorite, fav, f ⭐ Manage the favorited phrase(s) of the history of "generate" command.
help 🤝 Help of jrp.
completion 🔧 Generate the autocompletion script for the specified shell.
version 🔖 Show the version of jrp.
Flags:
-n, --number 🔢 number of phrases to generate (default 1, e.g: 10).
-p --prefix 💬 prefix of phrase(s) to generate.
-s --suffix 💬 suffix of phrase(s) to generate.
-n, --number 🔢 number of phrases to generate (default 1, e.g: 10)
-p --prefix 💬 prefix of phrase(s) to generate
-s --suffix 💬 suffix of phrase(s) to generate
-d --dry-run 🧪 generate phrase(s) without saving to the history
-P, --plain 📝 plain text output instead of table output
-h, --help 🤝 help for jrp
-v, --version 🔖 version for jrp
Arguments:
number 🔢 number of phrases to generate (e.g: 10).
number 🔢 number of phrases to generate (e.g: 10)
```

## 🌍 Environments

### 📁 Directory to store WordNet Japan sqlite database file

Default : `$XDG_DATA_HOME/jrp` or `$HOME/.local/share/jrp`

```sh
export JRP_WNJPN_DB_FILE_DIR=/path/to/your/directory
```

### 📁 Directory to store jrp sqlite database file

Default : `$XDG_DATA_HOME/jrp` or `$HOME/.local/share/jrp`

```sh
export JRP_DB_FILE_DIR=/path/to/your/directory
```

## 🔧 Installation

### 🐭 Using go

```
```sh
go install github.com/yanosea/jrp@latest
```

### 🍺 Using homebrew

```
```sh
brew tap yanosea/tap
brew install yanosea/tap/jrp
```
Expand All @@ -74,13 +99,13 @@ Go to the [Releases](https://github.com/yanosea/jrp/releases) and download the l

reinstall `jrp`!

```
```sh
go install github.com/yanosea/jrp@latest
```

### 🍺 Using homebrew

```
```sh
brew update
brew upgrade jrp
```
Expand All @@ -89,6 +114,45 @@ brew upgrade jrp

Download the latest binary from the [Releases](https://github.com/yanosea/jrp/releases) page and replace the old binary in your `$PATH`.

## 🧹 Uninstallation

### 🔧 Uninstall jrp

#### 🐭 Using go

```sh
rm $GOPATH/bin/jrp
sudo rm -fr $GOPATH/pkg/mod/github.com/yanosea/jrp@*
```

#### 🍺 Using homebrew

```sh
brew uninstall jrp
brew untap yanosea/tap/jrp
```

#### 📦 Download from release

Remove the binary you downloaded and placed in your `$PATH`.

### 🗑️ Remove data files

If you've set jrp envs, please replace `$HOME/.local/share/jrp` with envs you've set.
These below commands are in the case of default. Ofcourse you can remove whole the directory.

#### 💾 Remove WordNet Japan sqlite database file

```sh
rm $HOME/.local/share/jrp/wnjpn.db
```

#### 💾 Remove jrp sqlite database file

```sh
rm $HOME/.local/share/jrp/jrp.db
```

## 📃 License

[🔓MIT](./LICENSE)
Expand Down
2 changes: 2 additions & 0 deletions app/database/jrp/model/godoc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package model is a package for providing jrp model.
package model
17 changes: 17 additions & 0 deletions app/database/jrp/model/jrp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package model

import (
"github.com/yanosea/jrp/app/proxy/sql"
"github.com/yanosea/jrp/app/proxy/time"
)

// Jrp is a struct that represents jrp.
type Jrp struct {
ID int
Phrase string
Prefix *sqlproxy.NullStringInstance
Suffix *sqlproxy.NullStringInstance
IsFavorited int
CreatedAt *timeproxy.TimeInstance
UpdatedAt *timeproxy.TimeInstance
}
Loading

0 comments on commit 3dc5370

Please sign in to comment.