Tackle box is a declarative DSL for building modular workflows and code generators. Tool is plugins based and can easily be extended by writing additional hooks or importing external providers creating a web of interoperable CLIs.
Project description
tackle-box
Tackle-box is an experimental DSL for building modular code generators and declarative CLIs. Built as a fork of cookiecutter, it can make any config file into a CLI with both strong and weakly typed programmable flow control common to a general purpose programming language. Basically you can write a fully functional Turing-complete program out of a config file. It's wild.
With tackle-box, you can build:
- Modular code generators / repo scaffolding tools that can be updated over time
- Declarative makefile alternatives for advanced toolchain management
- Interactive glue code for infrastructure-as-code deployment strategies
- Generic utilities like SSH registries and dotfile managers
- Combinations of all of the above and anything else you can think of
If this project gets enough adoption / stars, it will be re-written in a compiled language. Its current goal is defining the syntax which should remain stable after a rewrite.
Features
- Makes arbitrary yaml / json / toml dynamic
- Embed loops, conditionals, and other custom logic
- Self documenting CLI to call logic
- Ships with a collection of over 100 hooks that act like plugins within your config file
- Modular design allows creating / importing new hooks easy
- Supports both python and declarative hooks which can be imported / called / defined in-line or within jinja templates
Install
Note: tackle can install dependencies on its own. Check docs for advanced installation methods to isolate tackle from your system python.
python -m venv env && source env/bin/activate
pip install tackle-box
Quick Demo: tackle robcxyz/tackle-hello-world
Use Cases
- Code Generation
- Declarative Utilities - wip
- Infrastructure-as-Code Management - wip
- Kubernetes Manifest Management - wip
- Toolchain Management - wip
- Repo Management - wip
Hello world
Check out the docs for >10 hello worlds that demonstrate the various aspects of the syntax with the simplest one using the print hook.
hello.yaml
hw->: print Hello world!
To run, call tackle hello.yaml
. Can also be version controlled -> tackle robcxyz/tackle-hello-world
.
Can also use loops, conditionals, and other base methods.
hello.yaml
the:
words:
- Hello
- cruel
- world!
hw->: print {{item}} --for the.words --if "item != 'cruel'"
New hooks can be made in python which under the hood is a pydantic model.
from tackle import BaseHook
class Greeter(BaseHook):
hook_type: str = "greeter"
target: str
args: list = ['target']
def exec(self):
print(f"Hello {self.target}")
Or can be defined inline within your tackle file..
greeter<-:
target: str
args: ['target']
exec<-:
hi->: print Hello {{target}}
And both can be called in the same way.
hello: world!
compact->: greeter {{hello}}
expanded:
->: greeter
target: {{hello}}
jinja_extension->: {{ greeter(hello) }}
# Or combinations of the above allowing chaining of hook calls.
With the declarative hooks being callable from the command line:
tackle hello.yaml --target world!
# Or from a github repo
tackle robcxyz/tackle-hello-world --checkout v0.1.0
Documentation can be embedded into the hooks.
<-:
help: This is the default hook
target:
type: str
description: The thing to say hello to
exec<-:
greeting->: select Who to greet? --choices ['world','universe']
hi->: greeter --target {{greeting}}
greeting-method<-:
help: A method that greets
# ... Greeting options / logic
greeter<-:
help: A reusable greeter object
target: str
exec<-:
hi->: print Hello {{target}}
Which when running tackle hello.yaml help
produces its own help screen.
usage: tackle hello.yaml [--target]
This is the default hook
options:
--target [str] The thing to say hello to
methods:
greeting-method A method that greets
greeter A reusable greeter object
Hooks can be imported, linked, and/or combined creating a web of CLIs.
Topics
- Writing Tackle Files
- Creating Providers
- Python Hooks
- Declarative Hooks
- Blocks and Flow Control
- Memory Management
- Special Variables
- Declarative CLIs - wip
- Modular CLIs - wip
Contributing
Contributions are welcome but please be advised of the following notes.
- This project uses conventional commits which generates the changelog with release-please-action in the release CI workflow. If commits have been made outside of this convention they will be squashed accordingly.
- For making changes to providers, please include test coverage using the existing fixtures and patterns from prior tests or communicate any suggestions that deviate from this style. Tests should be runnable from the test's directory and via
make test
. - For making changes to the core parser, please create a proposal first outlining your suggestions with examples before spending time working on code.
It is very easy to create new providers / hooks with tackle-box. Over time, it will adopt the same import pattern of what Ansible does where all provider / hooks (modules) are stored in version controlled locations. In the meantime, please feel free to contribute to this repository for hooks that have general applicability or create your own hooks in other repositories that are more bespoke / opinionated in nature.
Code of Conduct
Everyone interacting in the tackle-box project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the PyPA Code of Conduct.
Credit
Special thanks to the cookiecutter community for laying the basis for this project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file tackle-box-0.4.0.tar.gz
.
File metadata
- Download URL: tackle-box-0.4.0.tar.gz
- Upload date:
- Size: 182.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bb6c213524b23ccb7ff5e9d9438b6dda7661a8d9b6ac566987f4e4a8add26d9 |
|
MD5 | 57e9b464bddd1ee74f32dcd1fc572a63 |
|
BLAKE2b-256 | a1f5ff77d50cee5ec2b270e4650b6887065a3f38667cb59b7f0c8f37b6dca48c |
File details
Details for the file tackle_box-0.4.0-py3.10.egg
.
File metadata
- Download URL: tackle_box-0.4.0-py3.10.egg
- Upload date:
- Size: 466.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d25470019ed4290d547cbb4fd2055d05997428010736ab5c80b03d37f787d02 |
|
MD5 | aaf415fed6861f965c82d74bea6fac56 |
|
BLAKE2b-256 | 80f5046076d112a6dfcdc57e3efd57b6b087adcb3379d7cb5665e4ec6195266e |
File details
Details for the file tackle_box-0.4.0-py2.py3-none-any.whl
.
File metadata
- Download URL: tackle_box-0.4.0-py2.py3-none-any.whl
- Upload date:
- Size: 252.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1985050eb128e118e1f8a55d068cf9e50fc58502bc8e0ed5736b409bbb3961e2 |
|
MD5 | 05bcede9f944728dc6c1d573b4672466 |
|
BLAKE2b-256 | 08fec79ea065b3f097854c1176a4fde56533698204b477eb9ca3db61118f4c15 |