Plone command line interface - plonecli
Tags: plone
Published: 2020-12-03 19:35:08

---
title: Plone command line interface - plonecli
published: true
date: 2017-10-29 23:00:00 UTC
tags: plone
canonical_url: http://mrtango.planetcrazy.de/plone-command-line-interface-plonecli.html
---

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

During the after conference sprints in Barcelona, we ([MrTango](https://github.com/MrTango), [tmassman](https://github.com/tmassman) and [Gomez](https://github.com/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

```

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

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

```

#### Example

 ![Create addon with plonecli](http://mrtango.planetcrazy.de/images/plonecli_create_addon_optimized.gif)

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

```

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

```
$ plonecli add
content_type theme vocabulary

```

 ![Add a content_type to your package](http://mrtango.planetcrazy.de/images/plonecli_add_content_type_optimized.gif)

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

```

### Example

 ![Add a vocabulary to your package](http://mrtango.planetcrazy.de/images/plonecli_add_vocabulary_optimized.gif)

Add a vacobulary to your package

#### Build a Plone Addon

You can use the plonecli also to build the package:

```
$ plonecli build

```

This will run:

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

```

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

### Example

 ![Build your package with plonecli](http://mrtango.planetcrazy.de/images/plonecli_build_optimized.gif)

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
...

```

### Combine (chain) commands

You can combine commands like create, build and serve:

```
$ plonecli build serve

```

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

### Example

 ![Serve your package with plonecli](http://mrtango.planetcrazy.de/images/plonecli_serve_optimized.gif)

Serve your package with plonecli