Skip to main content

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

pypi python codecov main-tests

Tackle box is a tool for making modular code generators and declarative CLIs. It can make any config file dynamic with both strong and weakly typed programmable flow control common to a general purpose programming language. Basically you can write a fully functional CLI and Turing-complete program in yaml. It's wild.

Warning: Tool is in it's very early phases and only now considered stable enough to use. It may never reach 1.x version as, if it gets enough stars, it will be converted to a spec and re-written in rust (ie give it a star if you'd like to see that).

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
pip install tackle-box

Hello world

To call tackle, create a yaml file and run tackle hello-world.yaml.

Simply use the print hook.

hw->: print Hello world!

Which using jinja templating can be called in four different ways.

words: Hello world!
expanded:
  ->: print
  objects: "{{words}}"
compact->: print {{words}}
jinja_extension->: "{{ print(words) }}"
jinja_filter->: "{{ words | print }}"

And can also have interactive prompt hooks.

name->: input
target:
  ->: select Say hi to who?
  choices:
    - world
    - universe
hello->: print My name is {{name}}. Hello {{target}}!

Hooks can have loops, conditionals, and other base methods.

words:
  - Hello
  - cruel
  - world!
expanded:
  ->: print {{item}}
  for: words
  if: item != 'cruel'
compact->: print {{item}} --for words --if "item != 'cruel'"

Hooks can be written in python.

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 new hooks can be declaratively created with tackle.

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) }}"
jinja_filter->: "{{ hello | greeter }}"

Declarative hooks are strongly typed objects.

words<-:
  hi:
    type: str
    default: Hello
    regex: ^(Bonjour|Hola|Hello)
  target: str

p->: print {{item}} --for values(words(hi="Hello",target="world!"))

Which can have methods that extend the base.

words<-:
  hi:
    type: str
    default: Hello
    regex: ^(Bonjour|Hola|Hello)
  say<-:
    target: str
    exec:
      p->: print {{hi}} {{target}}

p->: words.say --hi Hello --target world!

And also support inheritance.

base<-:
  hi: Hello

words<-:
  extends: base
  say<-:
    target: str
    exec:
      p->: print {{hi}} {{target}}

p->: words.say --target world!

And last, everything can be imported / called remotely from github repos.

import-hello_>: import robcxyz/tackle-hello-world
call->: greeter world!
# Or
local-call->: tackle hello-world.yaml
remote-call->: tackle robcxyz/tackle-hello-world --version v0.1.0

Creating a web of declarative CLIs.

Topics

Roadmap

  • Declarative hook inheritance
  • Declarative schemas
  • Declarative methods
  • Cached providers
  • State management

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


Download files

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

Source Distribution

tackle-box-0.3.0b3.tar.gz (155.9 kB view details)

Uploaded Source

Built Distribution

tackle_box-0.3.0b3-py2.py3-none-any.whl (224.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file tackle-box-0.3.0b3.tar.gz.

File metadata

  • Download URL: tackle-box-0.3.0b3.tar.gz
  • Upload date:
  • Size: 155.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.13

File hashes

Hashes for tackle-box-0.3.0b3.tar.gz
Algorithm Hash digest
SHA256 42a489094fc2fae45ad86df601666fa7a705f1a20c81178ad97f49641780a4d0
MD5 f315d9880dab3c0d9fb9a902007f85e9
BLAKE2b-256 703d44c4f1e92378b5ea17ef33c3fa4700e557198a9ea9793817da9123349afa

See more details on using hashes here.

File details

Details for the file tackle_box-0.3.0b3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for tackle_box-0.3.0b3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 eb770673e33487e584ed6e628619db0ae58c2a8757e9e8c8349ca477e7f5cad4
MD5 5e91258c1e213ce6e2aa12b185b5784b
BLAKE2b-256 3bde597d1e1b384d290dc2b0a362b44a9816791cd25abd60e9a6e51f6c6cb122

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