Kirby3-plopfile: a CLI tool to generate and append to various files

The readme of the bnomei/kirby3-plopfile github repo is quiet long so will provide just a elevator pitch here.

Why should you use generators? They create code faster than you and less error prone.

You install the plugin, copy a premade plopfile.js to your project root and are ready to plop. The plugin provides you with more than 50 generators to create files and append to existing ones (plugin index.php and config files).

You can use the plugin with existing projects if you add a few markers like // @PLOP_EXT_ROUTE to your file.

After running a generator it will by default copy something like
code /home/bnomei/myproject/site/config/config.php:42:4
to your clipboard so you can jump right there with ctrl-v enter. Neat, right?

You can use just plop and choose a generator and fill its prompts step by step or you can do it all in one command and “bypass” the prompts. Here are some examples but it might be better to read the repos readme. :wink:

# $ = kirbys default root for that generator
plop blueprint $ pages blogpost
plop template $ blogpost
plop content "Consistency made simple!" blog blogpost
# _ is a "skipped-bypass" and will have you enter the title via plops CLI UI
plop content _ blog blogpost
plop snippet $ slideshow

# adding inline code to plugins
plop plugin myname myplugin
plop ext-collection myplugin allBlogpages

# some files need to be referenced in the plugin index.php to work
plop blueprint myplugin pages contactform
plop ext-blueprint myplugin contactform
plop template myplugin contactform
plop ext-template myplugin contactform

# some extensions do not have a file on their own but are inlined to index.php
plop ext-route myplugin form/submit '' POST

Hope you like it. If you have issues or questions please create a new issue. Thanks.

1 Like

in v1.0.6 support for upcoming new methods and models has been added (kirby v3.6)

  • ext-block-method (folder, key, params, todo)
  • ext-block-model (folder, key, value)
  • ext-blocks-method (folder, key, params, todo)
  • ext-layoutcolumn-method (folder, key, params, todo)
  • ext-layout-method (folder, key, params, todo)
  • ext-layouts-method (folder, key, params, todo)

version 1.2.0 adds generators to support the new kirby CLI commands.

difference to kirby CLI generators: my plop based CLI tool for kirby does not create empty files (like the kirby cli does) but bases them on templates configurable with options to get you started even more quickly. it can also append to existing files (with proper setup).