DEV Community

Maik Derstappen
Maik Derstappen

Posted on • Originally published at mrtango.planetcrazy.de on

Plone command line interface - plonecli

PloneConf after conference sprint report on plonecli and bobtemplates.plone.

During the after conference sprints in Barcelona, we (MrTango, tmassman and Gomez) created a command line client for developing Plone packages. The plonecli is mainly a wrapper around mr.bob and bobtemplates.plone, but can also used with other bobtemplates. The plonecli adds to the previous work on refactoring and modulizing the bobtemplates.plone templates, a simple and easy to use command line frontend.

Features

  • allow bobtemplates to be registered for plonecli
  • list available bobtemplates for the current context
  • standalone and subtemplates
  • auto completion of commands and available templates
  • command chaining

Usage

Create a Plone Addon packages

To create a Plone Addon with the plonecli, you can just use the create command:

$ plonecli create addon src/collective.todos

Enter fullscreen mode Exit fullscreen mode

If you want to know what templates are available, you can either use the -l/--list-templates option or just press TAB-Key twice.

$ plonecli --list-templates
Available mr.bob templates:
 - buildout
 - addon
  - vocabulary
  - theme
  - content_type
 - theme_package

Enter fullscreen mode Exit fullscreen mode

Example

Create addon with plonecli

Create addon with plonecli

Add a content_type to your Plone Addon

To add a content_type to an existing Plone Addon package, you can just use the add command inside the package:

$ cd src/collective.todos
$ plonecli add content_type

Enter fullscreen mode Exit fullscreen mode

The -l/--list-templates and auto completion works also for subtemplates (the add command).

$ plonecli add
content_type theme vocabulary

Enter fullscreen mode Exit fullscreen mode

Add a content_type to your package

Add a content_type to your package

Add a vocabulary to your Plone Addon

To add a Plone vocabulary, you can use the add command with the vocabulary subtemplate:

$ plonecli add vocabulary

Enter fullscreen mode Exit fullscreen mode

Example

Add a vocabulary to your package

Add a vacobulary to your package

Build a Plone Addon

You can use the plonecli also to build the package:

$ plonecli build

Enter fullscreen mode Exit fullscreen mode

This will run:

$ virtualenv .
$ ./bin/pip install -r requirements.txt --upgrade
$ ./bin/buildout

Enter fullscreen mode Exit fullscreen mode

in your target directory. You can always run the 3 steps explicit by using the commands virtualenv,requirements, buildout instead of build. If you want to reset your build use the --clean option on build. This will clear your virtualenv before installing the requirements and also running buildout with -n to get the newest versions.

Example

Build your package with plonecli

Build your package with plonecli

Serve the development Plone site of the package

The plonecli also provides a serve command which will start the Plone instance in foreground and provide a link to open it in the browser:

$ plonecli serve
RUN: ./bin/instance fg

INFO: Open this in a Web Browser: http://localhost:8080
INFO: You can stop it by pressing CTRL + c

2017-10-30 14:21:01 INFO ZServer HTTP server started at Mon Oct 30 14:21:01 2017
    Hostname: 0.0.0.0
    Port: 8080
...

Enter fullscreen mode Exit fullscreen mode

Combine (chain) commands

You can combine commands like create, build and serve:

$ plonecli build serve

Enter fullscreen mode Exit fullscreen mode

This will first run all the build steps and then serve the Plone site

Example

Serve your package with plonecli

Serve your package with plonecli

Top comments (0)