jrp

module
v2.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2025 License: MIT

README ΒΆ

golangci-lint release

🎲 jrp

Latest Release
Coverage Report
demo

ℹ️ About

jrp generates Japanese random phrases.
This tool uses WordNet Japan sqlite database file.

πŸ“Ÿ CLI

You can generate and save the generated phrases to the history and manage them via the CLI.
Also, you can favorite the generated phrases and manage them.

πŸ’» Usage
Available Subcommands:
  download,    dl,   d  πŸ“¦ Download WordNet Japan sqlite database file from the official web site.
  generate,    gen,  g  ✨ Generate Japanese random phrases.
                           You can abbreviate "generate" sub command. ("jrp" and "jrp generate" are the same.)
  interactive, int,  i  πŸ’¬ Generate Japanese random phrases interactively.
  history,     hist, h  πŸ“œ Manage the histories of the "generate" command.
  favorite,    fav,  f  ⭐ Favorite the histories of the "generate" command.
  unfavorite,  unf,  u  ❌ Unfavorite the favorited histories of the "generate" command.
  completion   comp, c  πŸ”§ Generate the autocompletion script for the specified shell.
  version      ver,  v  πŸ”– Show the version of jrp.
  help                  🀝 Help for jrp.

Flags:
  -n, --number       πŸ”’ number of phrases to generate (default 1, e.g. : 10)
  -p, --prefix       πŸ”‘ prefix of phrases to generate
  -s, --suffix       πŸ”‘ suffix of phrases to generate
  -d, --dry-run      πŸ§ͺ generate phrases without saving as the histories
  -f, --format       πŸ“ format of the output (default "table", e.g. : "plain")
  -i, --interactive  πŸ’¬ generate Japanese random phrases interactively
  -t, --timeout      βŒ› timeout in seconds for the interactive mode (default 30, e.g. : 10)
  -h, --help         🀝 help for jrp
  -v, --version      πŸ”– version for jrp

Argument:
  number  πŸ”’ number of phrases to generate (e.g. : 10)
πŸ’¬ Interactive mode

demo_interactive

jrp can generate Japanese random phrases interactively.
You can favorite, save, skip, and exit interactively while generating phrases.

To use this mode, run either command below.

# Those commands below are equivalent.
# And they have their aliases. Please check the help message.
jrp interactive
# or
jrp --interactive
# or
jrp generate interactive
# or
jrp generate --interactive

Press either key below for your action.

  • u
    • Favorite, continue.
  • i
    • Favorite, exit.
  • j
    • Save, continue.
  • k
    • Save, exit.
  • m
    • Skip, continue.
  • other
    • Skip, exit.
🌍 Environments
πŸ“ Connection string of WordNet Japan database

Default : $XDG_DATA_HOME/jrp/wnjpn.db or $HOME/.local/share/jrp/wnjpn.db

export JRP_WNJPN_DB=/path/to/your/directory/wnjpn.db
πŸ“ Connection string of jrp database

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

export JRP_DB=/path/to/your/directory/jrp.db
πŸ”§ Installation
🐭 Using go
go install github.com/yanosea/jrp/v2/app/presentation/cli/jrp@latest
🍺 Using homebrew
brew tap yanosea/tap
brew install yanosea/tap/jrp
πŸ“¦ Download from release

Go to the Releases and download the latest binary for your platform.

✨ Update
🐭 Using go

Reinstall jrp!

go install github.com/yanosea/jrp/v2/app/presentation/cli/jrp@latest
🍺 Using homebrew
brew update
brew upgrade jrp
πŸ“¦ Download from release

Download the latest binary from the Releases page and replace the old binary in your $PATH.

🧹 Uninstallation
πŸ”§ Uninstall jrp
🐭 Using go
rm $GOPATH/bin/jrp
# maybe you have to execute with sudo
rm -fr $GOPATH/pkg/mod/github.com/yanosea/jrp*
🍺 Using homebrew
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
rm $HOME/.local/share/jrp/wnjpn.db
πŸ’Ύ Remove jrp sqlite database file
rm $HOME/.local/share/jrp/jrp.db

🌐 API Server

jrp also provides RESTful API server that you can use to get Japanese random phrases.

πŸ’» Usage
# If you installed with go, you can run the server with the command below.
jrp-server
# If you cloned the repository, you can run the server with the command below.
go run app/presentation/api/jrp-server/main.go
# Then, you can access the API server with the URL below.
curl http://localhost:8080/api/jrp
πŸ“š API Documentation

Swagger documentation is available at: http://localhost:8080/swagger/index.html

Available Endpoints
Method Path Description
GET /api/jrp Get a generated Japanese random phrase
⚑ Caution

You have to download the WordNet Japan sqlite database file from WordNet Japan before running the server.

🌍 Environments
🚒 Port number

Default : 8080

export JRP_SERVER_PORT=8080
πŸ“ Connection string of WordNet Japan database

Default : $XDG_DATA_HOME/jrp/wnjpn.db or $HOME/.local/share/jrp/wnjpn.db

export JRP_SERVER_WNJPN_DB=/path/to/your/directory/wnjpn.db
πŸ”§ Installation
🐭 Using go
go install github.com/yanosea/jrp/v2/app/presentation/api/jrp-server@latest
πŸš€ With source code
git clone github.com/yanosea/jrp
cd jrp
go run app/presentation/api/jrp-server/main.go
✨ Update
🐭 Using go

Reinstall jrp-server!

go install github.com/yanosea/jrp/v2/app/presentation/api/jrp-server@latest
πŸš€ With source code

Pull the latest changes into your local repository.

🧹 Uninstallation
πŸ”§ Uninstall jrp-server
🐭 Using go
rm $GOPATH/bin/jrp
# maybe you have to execute with sudo
rm -fr $GOPATH/pkg/mod/github.com/yanosea/jrp*
πŸš€ With source code

Remove the directory you cloned.

πŸ—‘οΈ Remove WordNet Japan sqlite database file

If you've set jrp-server 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.

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

πŸ“ƒ License

πŸ”“MIT

πŸ–ŠοΈ Author

🏹 yanosea

πŸ”₯ Motivation

I love the smart phone application PhrasePlus!
I wanted to run an application with equivalent functionality to this in the terminal, so I created it!

🀝 Contributing

Feel free to point me in the right directionπŸ™

Directories ΒΆ

Path Synopsis
app
application/jrp
Package jrp provides the usecase of the jrp.
Package jrp provides the usecase of the jrp.
application/wnjpn
Package wnjpn provides the usecase of the wnjpn.
Package wnjpn provides the usecase of the wnjpn.
config
Package config provides the configuration of the jrp application.
Package config provides the configuration of the jrp application.
domain/jrp/history
Package history provides the domain of the history.
Package history provides the domain of the history.
infrastructure/database
Package database is a generated GoMock package.
Package database is a generated GoMock package.
infrastructure/jrp/repository
Package repository provides the repository for the jrp database.
Package repository provides the repository for the jrp database.
infrastructure/wnjpn/query_service
Package query_service provides the query service for the WordNet Japan sqlite database.
Package query_service provides the query service for the WordNet Japan sqlite database.
presentation/api/jrp-server
Package main provides the entry point of the api application.
Package main provides the entry point of the api application.
presentation/api/jrp-server/config
Package config provides the configuration of the jrp server application.
Package config provides the configuration of the jrp server application.
presentation/api/jrp-server/formatter
Package formatter provides the formatter for the jrp.
Package formatter provides the formatter for the jrp.
presentation/api/jrp-server/server
Package server provides the server application for the jrp.
Package server provides the server application for the jrp.
presentation/api/jrp-server/server/jrp
Package jrp provides the entry points for the Jrp server client.
Package jrp provides the entry points for the Jrp server client.
presentation/cli/jrp
Package main provides the entry point of the cli application.
Package main provides the entry point of the cli application.
presentation/cli/jrp/command
Package command is a generated GoMock package.
Package command is a generated GoMock package.
presentation/cli/jrp/command/jrp
Package jrp provides the sub commands for the jrp.
Package jrp provides the sub commands for the jrp.
presentation/cli/jrp/command/jrp/completion
Package completion provides the sub commands for the jrp completion.
Package completion provides the sub commands for the jrp completion.
presentation/cli/jrp/command/jrp/generate
Package generate provides the sub commands for the jrp generate.
Package generate provides the sub commands for the jrp generate.
presentation/cli/jrp/command/jrp/history
Package history provides the sub commands for the jrp history.
Package history provides the sub commands for the jrp history.
presentation/cli/jrp/config
Package config provides the configuration of the jrp cli application.
Package config provides the configuration of the jrp cli application.
presentation/cli/jrp/formatter
Package formatter provides the formatter for the jrp.
Package formatter provides the formatter for the jrp.
presentation/cli/jrp/presenter
Package presenter provides the presenter for the jrp.
Package presenter provides the presenter for the jrp.
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
pkg
proxy
Package proxy is a generated GoMock package.
Package proxy is a generated GoMock package.
utility
Package utility is a generated GoMock package.
Package utility is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL