Developer Tools

Introduction

Cement ships with a CLI utility that includes tools and helpers for application developement. It is in-itself an application Built on Cement™, and can serve as a working example of some of the key features of the framework.
See: $ cement --help
The Cement CLI uses the builtin Generate Extension in order to easily create new projects, extensions, plugins, or scripts.
See $ cement generate --help

Creating Your First Project Built on Cement™

Using the Cement Developer Tools CLI, you can quickly generate a new project:
Note: Press <ENTER> in order to take the default values for myapp:
1
$ cement generate project ./myapp
2
INFO: Generating cement project in ./myapp
3
App Label [myapp]:
4
App Name [My Application]:
5
App Class Name [MyApp]:
6
App Description [MyApp Does Amazing Things!]:
7
Creator Name [John Doe]:
8
Creator Email [[email protected]]:
9
Project URL [https://github.com/johndoe/myapp/]:
10
License [unlicensed]:
Copied!
We have just generated a new project in the directory ./myapp. The included README.md includes general information that is built-in to your new project out-of-the box including how to setup a development environment, run tests, push packages to PyPi, and deploy via Docker.

Customizing Templates

The Generate Extension reads templates from any template directory paths, therefore adding your own templates to Cement is as simple as adding a template directory to Cement's configuration file, cloning a builtin template, and then generating from your own templates using the same utility.
Add the following to ~/.cement.yml:
1
cement:
2
template_dir: ~/templates
Copied!
Then clone an existing template:
1
$ cement generate project \
2
--clone ~/templates/generate/my-template
Copied!
Your template is now part of Cement! Customize it to your liking, and use it in the same way as the builtin templates:
1
$ cement generate --help
2
usage: cement generate [-h]
3
{project,script,plugin,extension,my-template}
4
...
5
6
optional arguments:
7
-h, --help show this help message and exit
8
9
sub-commands:
10
{project,script,plugin,extension,my-template}
11
project generate project from template
12
script generate script from template
13
plugin generate plugin from template
14
extension generate extension from template
15
my-template generate my-template from template
16
Copied!
Last modified 3yr ago