Metadata-Version: 2.1
Name: tackle-box
Version: 0.1.0a1
Summary: Declarative DSL for creating workflows, CLIs, and generating code. Extends cookiecutter templates with modules, loops, conditionals, and plugins to perform a wide array of actions.
Home-page: https://github.com/robcxyz/tackle-box
Author: Rob Cannon
Author-email: robc.io.opensource@gmail.com
License: BSD
Keywords: cookiecutter,tackle,Python,projects,project templates,Jinja2,skeleton,scaffolding,project directory,package,packaging
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: binaryornot (>=0.4.4)
Requires-Dist: Jinja2 (<3.0.0)
Requires-Dist: click (>=7.0)
Requires-Dist: poyo (>=0.5.0)
Requires-Dist: jinja2-time (>=0.2.0)
Requires-Dist: python-slugify (>=4.0.0)
Requires-Dist: requests (>=2.23.0)
Requires-Dist: PyInquirer (>=1.0.3)
Requires-Dist: PyYAML (>=5.3)
Requires-Dist: oyaml (>=v1.0)
Requires-Dist: pyhcl (>=0.4.4)
Requires-Dist: distro (>=1.5.0)
Requires-Dist: rich (>=3.3.0)
Requires-Dist: pydantic (>=1.6.0)
Provides-Extra: all
Requires-Dist: freezegun ; extra == 'all'
Requires-Dist: toml (>=0.10.0) ; extra == 'all'
Requires-Dist: pytest ; extra == 'all'
Requires-Dist: boto3 (>=1.14.0) ; extra == 'all'
Requires-Dist: azure-mgmt-compute (>=18.0.0) ; extra == 'all'
Requires-Dist: dopy (>=0.3.7) ; extra == 'all'
Requires-Dist: google-api-python-client (>=1.9) ; extra == 'all'
Requires-Dist: pytest-mock ; extra == 'all'
Requires-Dist: pyhcl (>=0.4.4) ; extra == 'all'
Requires-Dist: semver (>=2.13.0) ; extra == 'all'
Requires-Dist: ptyprocess ; extra == 'all'
Requires-Dist: pytest-cov ; extra == 'all'
Requires-Dist: azure-mgmt-subscription (>=0.6.0) ; extra == 'all'
Provides-Extra: aws
Requires-Dist: boto3 (>=1.14.0) ; extra == 'aws'
Provides-Extra: azure
Requires-Dist: azure-mgmt-compute (>=18.0.0) ; extra == 'azure'
Requires-Dist: azure-mgmt-subscription (>=0.6.0) ; extra == 'azure'
Provides-Extra: dev
Requires-Dist: freezegun ; extra == 'dev'
Requires-Dist: pytest-mock ; extra == 'dev'
Requires-Dist: ptyprocess ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: pytest ; extra == 'dev'
Provides-Extra: digitalocean
Requires-Dist: dopy (>=0.3.7) ; extra == 'digitalocean'
Provides-Extra: gcp
Requires-Dist: google-api-python-client (>=1.9) ; extra == 'gcp'
Provides-Extra: terraform
Requires-Dist: pyhcl (>=0.4.4) ; extra == 'terraform'
Requires-Dist: semver (>=2.13.0) ; extra == 'terraform'
Provides-Extra: toml
Requires-Dist: toml (>=0.10.0) ; extra == 'toml'

# Tackle Box

[![pypi](https://img.shields.io/pypi/v/tackle-box.svg)](https://pypi.python.org/pypi/tackle-box)
[![python](https://img.shields.io/pypi/pyversions/tackle-box.svg)](https://pypi.python.org/pypi/tackle-box)
[![Build Status](https://travis-ci.org/robcxyz/tackle-box.svg?branch=master)](https://travis-ci.org/robcxyz/tackle-box)
[![codecov](https://codecov.io/gh/robcxyz/tackle-box/branch/master/graphs/badge.svg?branch=master)](https://codecov.io/github/robcxyz/tackle-box?branch=master)

* Tackle Box Documentation: [https://robcxyz.github.io/tackle-box](https://robcxyz.github.io/tackle-box)
    * [API Docs](https://robcxyz.github.io/tackle-box/docs/_build/html/cookiecutter.operators.html#submodules)
* GitHub: [https://github.com/robcxyz/tackle-box](https://github.com/cookiecutter/cookiecutter)
* PyPI: [https://pypi.org/project/tackle-box/](https://pypi.org/project/tackle-box/)
* Free and open source software: [BSD license](https://github.com/tackle-box/cookiecutter/blob/master/LICENSE)

Tackle box is a DSL for easily creating CLIs, workflows, and generating code from templates. The framework is modular and empowered by a collection of hooks to easily extend functionality. Based off a fork of [cookiecutter](https://github.com/cookiecutter/cookiecutter), this tool evolved from being a code generator to connecting git repositories into a web of CLIs.

### Quick Demo

<!--  TODO: Refactor -->
```
pip3 install tackle-box
tackle https://github.com/robcxyz/tackle-demos
```

### 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 [hook](tackle/models.py). Loops and conditionals are triggered by rendering [jinja](https://github.com/pallets/jinja) expressions per the example below. Other cookiecutters can be called from a single tackle box to knit together modularized components.

`tackle.yaml`
```yaml
---
name:
  type: input # Input prompt which is stored in `name`
  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 # Map for choices interpretted as {key: question}
    - walk-across-bridge: What do you mean? African or European swallow?

bad_outcome:
  type: print
  statement: Wrong answer {{ name }}... # Render the `name` variable
  when: "{{ outcome == 'flung-off-bridge' }}" # Conditionals need to evaluate as booleans

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

democmd:
  type: command # Run arbitrary system commands and return stdout
  command: pwd

output:
  type: pprint # Pretty print the output
  output: "{{ this }}" # Special var that contains a dictionary of all the value
```

Each hook is called via its `type` which, in the case of the `input` hook, can be looked up in the [docs]() or by looking at the [source code]() directly.

Prompts are enhanced by extending the functionality from [PyInquirer](https://github.com/CITGuru/PyInquirer) as a set of hooks as noted by the types `input`, `select`, and `checkbox`. Writing new hooks is super simple as seen in the `print` hook:

### Hooks and Providers



[`cookiecuttuer/providers/hooks/print.py`](tackle/operators/print.py)

```python
from tackle.models import BaseHook
from typing import Union

class PrintOperator(BaseHook):
    type: str = 'print'
    out: Union[dict, list, str] = None

    def execute(self):
        print(self.out)
        return self.out
```

Hooks are built with pydantic by inheriting from the [BaseHook](tackle/models.py) that makes a number of useful methods and attributes available.

#### Base Methods

A number of useful methods are available when executing any hook. Here is a breif example of all of them being used.

```yaml
this:
  type: a_hook
  chdir: /path/to/some/dir # Changes to the dir before executing
  loop: # Expects a list, creates `item` and `index` variables in loop
    - foo
    - bar
  when: "{{ item == 'foo' }}" # Jinja expression that evaluates to boolean
  merge: True # Merge the outputs to the upper level context
```

For further documentation on base methods, see check out [the docs]().



### Providers

Providers are groups of hooks and templates to


### Hooks

Around 50 different hooks are currently available with more coming down the line. To understand how to use them, please refer to the [API Docs](https://robcxyz.github.io/tackle-box/docs/_build/html/cookiecutter.operators.html#submodules).

The main type of operators are derivations of [PyInquirer](https://github.com/CITGuru/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](https://github.com/CITGuru/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.


