Skip to main content

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.

Metadata

Release files for nukikata 2.0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nukikata 2.0.0.3
File Size Uploaded Provenance Actions
nukikata-2.0.0.3.tar.gz 188.8 kB Without provenance Details for nukikata-2.0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nukikata 2.0.0.3
File Interpreter ABI Platform Actions
nukikata-2.0.0.3-py2.py3-none-any.whl Python 2, Python 3 none any Details for nukikata-2.0.0.3-py2.py3-none-any.whl

Total release size: 258.0 kB

Release files / nukikata-2.0.0.3.tar.gz

Download URL nukikata-2.0.0.3.tar.gz
Size 188.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f4eb4f71cc84548ec4a680f389809e933d5120cd145750cba3daa662f3f50b5a
BLAKE2b-256 checksum
How to use checksums
8c00916d0dc34b559456cd827cfee6e04d99a0202df6058c1567cff108818113
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / nukikata-2.0.0.3-py2.py3-none-any.whl

Download URL nukikata-2.0.0.3-py2.py3-none-any.whl
Size 69.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
40ab3c45f2a02d452e50c9c8a8cb28c7b927baa067897e1eddbdf8b687f722ff
BLAKE2b-256 checksum
How to use checksums
e0c8d0cb4eba257ff02cfd0c682b8899450d834db89b3f28010372b5bb159f9f
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for nukikata 2.0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page