LogoLogo
Official SiteAPI Reference
stable/3.0
stable/3.0
  • Cement Developer Guide
  • Release Information
    • What's New!
    • Upgrading
    • ChangeLog
    • Deprecations
  • Getting Started
    • Installation
    • Developer Tools
    • Framework Overview
    • Beginner Tutorial
      • Part 1: Creating Your First Project
      • Part 2: Adding Features
      • Part 3: Extending a Project
      • Part 4: Making Everything Legit
  • Core Foundation
    • Interfaces and Handlers
    • Hooks
    • Configuration Settings
    • Arguments
    • Logging
    • Controllers
    • Output Rendering
    • Caching
    • Mail Messaging
    • Framework Extensions
    • Application Plugins
    • Templating
  • Utilities
    • Filesystem
    • Shell
    • Miscellaneous
  • Extensions
    • Alarm
    • Argparse
    • Colorlog
    • ConfigParser
    • Daemon
    • Dummy
    • Generate
    • Jinja2
    • Json
    • Logging
    • Memcached
    • Mustache
    • Plugin
    • Print
    • Redis
    • Scrub
    • SMTP
    • Tabulate
    • Yaml
    • Watchdog
  • Additional Topics
    • Extending The App Object
    • Unit Testing
    • Cleanup
    • Signal Handling
    • Pipenv
    • Autocomplete
    • Profiling with cProfile
    • Debugging with VSCode
  • Environment Variables
  • Terminology
  • Contributing
  • Privacy Policy
Powered by GitBook
On this page
  • Introduction
  • Creating Your First Project Built on Cement™
  • Customizing Templates
  1. Getting Started

Developer Tools

PreviousInstallationNextFramework Overview

Last updated 6 months ago

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.

Install additional dependencies:

$ pip install cement[cli]

See:

$ cement --help

The Cement CLI uses the builtin 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:

$ cement generate project ./myapp
INFO: Generating cement project in ./myapp
App Label [myapp]:
App Name [My Application]:
App Class Name [MyApp]:
App Description [MyApp Does Amazing Things!]:
Creator Name [John Doe]:
Creator Email [john.doe@example.com]:
Project URL [https://github.com/johndoe/myapp/]:
License [unlicensed]:

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

Add the following to ~/.cement.yml:

cement:
    template_dir: ~/templates

Then clone an existing template:

$ cement generate project \
    --clone ~/templates/generate/my-template

Your template is now part of Cement! Customize it to your liking, and use it in the same way as the builtin templates:

$ cement generate --help
usage: cement generate [-h]
                       {project,script,plugin,extension,my-template}
                       ...

optional arguments:
  -h, --help            show this help message and exit

sub-commands:
  {project,script,plugin,extension,my-template}
    project             generate project from template
    script              generate script from template
    plugin              generate plugin from template
    extension           generate extension from template
    my-template         generate my-template from template
    

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

Generate Extension
Generate Extension