Skip to main content

Fork of cookiecutter - https://github.com/cookiecutter/cookiecutter The most popular command-line utility to create projects from project templates, e.g. creating a Python package project from a Python package project template.

Project description

nukikata

Japanese for cookiecutter: クッキーの抜き型 - Kukkī no nukikata | Direct translation: To shape or mold

pypi python Build Status codecov

Fork of

Cookiecutter

Cookiecutter is the worlds most popular code scaffolding tool with over 4 thousand open source cookiecutters available today. This fork includes many additional features including:

  • Loops
  • Conditionals
  • Plugins

Inspired by Ansible's syntax, this project aims to be a flexible declarative CLI that is easy to write operators for to extend functionality. It was originally built to extend cookiecutter to include conditionals and loops in the configuration file format. We are now looking at it as an upstream declarative CLI sandbox to prove out patterns that can either be integrated back into cookiecutter or fit a variety of other use cases.

Quick Demo

pip3 install nukikata
nukikata https://github.com/insight-infrastructure/nukikata-demos

Note: If you experience installation errors try pip3 install nukikata --no-binary :all:.

Features

All cookiecutter features are supported in addition to loops, conditionals, and plugins. These features are only available to supplied dictionary objects with a type key to trigger the associated operator. Loops and conditionals are triggered by rendering jinja expressions per the example below. Other cookiecutters can be called from a single nukikata to knit together modularized components.

nuki.yaml

---
name:
  type: input # Input box
  message: What is your name?

colors:
  type: checkbox # Multi selector - returns a list
  message: What are your favorite colors?
  choices:
    - blue
    - green
    - grey

outcome:
  type: select # Single selector - returns a string
  message: What is the airspeed velocity of an unladen swallow??
  choices:
    - flung-off-bridge: I donno
    - walk-across-bridge: What do you mean? African or European swallow?

bad_outcome:
  type: print
  statement: Wrong answer {{ nuki.name }}...
  when: "{{ nuki.outcome == 'flung-off-bridge' }}"

color_essays:
  type: input
  message: Please tell me how much you like the color {{nuki.item}}?
  default: Oh color {{nuki.item}}, you are so frickin cool... # loops over nuki.colors
  loop: "{{ nuki.colors }}"
  when: "{{ nuki.colors|length > 1 }}"

democmd:
  type: command
  command: pwd

dump_yaml:
  type: yaml
  contents: "{{ nuki }}"
  path: "{{ calling_directory }}/output.yaml"

Here the jinja default context key goes to the name of file - ie {{ nuki.<> }} but can be customized if needed. We can also see the use of a special variable

Prompts are enhanced by extending the functionality from PyInquirer as a set of operators as noted by the types input, list, and checkbox. Writing new operators is super simple as seen in the print operator:

cookiecuttuer/operators/print.py

class PrintOperator(BaseOperator):
    type = 'print'
    def __init__(self, *args, **kwargs):
        super(PrintOperator, self).__init__(*args, **kwargs)

    def _execute(self):
        print(self.operator_dict['statement'])
        return self.operator_dict['statement']

New operator PRs welcome. We're aiming to interface with various APIs and popular libraries to create simple ways to conditionally call and loop through popular methods.

Operators

Over 35 different operators are currently available with more coming down the line. To understand how to use them, please refer to the API Docs.

The main type of operators are derivations of PyInquirer which greatly enhanced the capabilities of the original cookiecutter due to the ability to use multi-select inputs that return lists. Please inspect the PyInquirer API docs to understand the interface. All features are supported except for validation and filter which is not supported and when which is implemented in jinja.

To see a number of good examples of the types of interfaces available for each operator, consider downloading the demo above and walking through the syntax.

Note to Users and Developers

This is a very early WIP but has long term ambitions of being a sort of swiss army knife for management of configuration files and boilerplate. Please consider contributing or leaving your comments in the issues section on where you see this project going and what features you would like added.

This project intends on being an edge release of cookiecutter and would not have been possible were it not for the orginal maintainers of that repository. Development in this repository is meant to be a proving ground for features that could be implemented and merged into the original cookiecutter repository. Please consider supporting both projects.

Windows will not have first class support. Several operators are built for POSIX systems. PRs welcome to build in full support. Basic features like PyInquirer style prompts are supported.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nukikata-2.0.0.3.tar.gz (188.8 kB view details)

Uploaded Source

Built Distribution

nukikata-2.0.0.3-py2.py3-none-any.whl (69.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file nukikata-2.0.0.3.tar.gz.

File metadata

  • Download URL: nukikata-2.0.0.3.tar.gz
  • Upload date:
  • Size: 188.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for nukikata-2.0.0.3.tar.gz
Algorithm Hash digest
SHA256 f4eb4f71cc84548ec4a680f389809e933d5120cd145750cba3daa662f3f50b5a
MD5 f8f639a5fa5880240a9b43b491baf5b5
BLAKE2b-256 8c00916d0dc34b559456cd827cfee6e04d99a0202df6058c1567cff108818113

See more details on using hashes here.

File details

Details for the file nukikata-2.0.0.3-py2.py3-none-any.whl.

File metadata

  • Download URL: nukikata-2.0.0.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 69.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for nukikata-2.0.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 40ab3c45f2a02d452e50c9c8a8cb28c7b927baa067897e1eddbdf8b687f722ff
MD5 47310270cdf43b4434bc0c6fbf0c523f
BLAKE2b-256 e0c8d0cb4eba257ff02cfd0c682b8899450d834db89b3f28010372b5bb159f9f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page