kopl
is a command-line tool designed to streamline the development of
plugins for KOReader. It helps with project initialization, static code analysis,
and dependency management for Lua-based KOReader plugins.
- Project Initialization: Quickly set up a new KOReader plugin project with the necessary file structure and configuration.
- Static Code Analysis: Integrate
luacheck
to perform static analysis on your Lua code, helping to identify potential issues and enforce coding standards.kopl
automatically handles the installation and setup ofluacheck
andluarocks
if they are not found in your system's PATH. - Deployment: Quickly deploy your local koplugin project to your device
- Install: Install remotely hosted plugins onto your device
Prerequisites:
- Go
- Git
- LuaRocks (optional,
kopl
can try to installluacheck
vialuarocks
if needed)
Example using go install
:
go install github.com/Consoleaf/kopl@latest
WARNING: This tool requires HTTP Inspector to be enabled!
To create a new KOReader plugin project, use the init
command:
kopl init my-awesome-plugin.koplugin
This will create a new directory my-awesome-plugin.koplugin
with the basic
project structure and necessary files like _meta.lua
and main.lua
.
To run luacheck
on your project and perform static analysis:
kopl check
kopl
will look for luacheck
in your PATH.
If not found, it will attempt to install it using luarocks
.
Usage:
kopl deploy [flags] <path>
kopl deploy ~/projects/hello.koplugin
Usage:
kopl install [flags] <path>
kopl install Consoleaf/repl.koplugin
Needs repl.koplugin to work. It will be automatically installed if not present.
Usage:
kopl repl [flags]
In the REPL, KOReader's state is available as a global ui
:
$ kopl repl
>>>: print(ui.Repl.fullname)
[OUT] Repl
[RET] <nil>
This project is licensed under the MIT License - see the LICENSE
file for details.