Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
robcxyz committed Apr 8, 2021
0 parents commit e11248f
Show file tree
Hide file tree
Showing 64 changed files with 1,479 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Run tests

on:
- push

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
with:
path: "${{ github.repository }}"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements_dev.txt
tox .
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.idea/
.vscode
env/

!demos/gallery/tackle.yaml
demos/gallery/*
ouput.json

before.yaml
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# tackle-demo

Simple demo to introduce the format and features for [`tackle-box`](https://github.com/geometry-labs/tackle-box)

```
pip3 install tackle-box
tackle https://github.com/robcxyz/tackle-demo
```

This demo walks you through many of the aspects of tackle boxes DSL.

```shell
? What demos do you want to do? (<up>, <down> to move, <space> to select, <a> to toggle, <i> to invert)
❯○ Monty Python basic demo
○ Embedded tackle boxes
○ A tutorial of all the hooks and providers
○ A tutorial on useful patterns with jinja
○ Galllery of the most popular cookiecutters
```

### Basic Demo

Simply write your tackle box per this format. The key in the jinja syntax defaults to the context filename for the template, in this case `yaml`.

A `tackle.yaml` file placed in a directory and run with `tackle .` would call the script.
```yaml
---
name:
type: input
message: What is your name?

colors:
type: checkbox
message: What are your favorite colors?
choices:
- blue
- green
- grey

wingspeed:
type: select
message: What is the airspeed velocity of an unladen swallow??
choices:
- I donno
- What do you mean? African or European swallow?

bad_outcome:
type: print
statement: Wrong answer {{ name }}... (Flung off bridge)
when: "{{ 'I donno' in wingspeed }}"

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 }}"
when: "{{ colors|length > 0 }}"
```
43 changes: 43 additions & 0 deletions demos/all-providers/providers/aws/tackle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---

aws_enable:
type: confirm
message: |
You can route various AWS Calls that are common. Right now
we have some basic helpers that wrap boto commands.
regions:
type: aws_regions

regions_blurb:
type: confirm
message: |
Here is an example of the regions hook:
regions:
type: aws_regions
It outputs a list per this output:
{% raw %}
{{ regions }} = {% endraw %}{{ aws.regions }}
azs:
type: aws_azs
regions:
- us-east-1
- us-east-2

azs_blurb:
type: confirm
message: |
Here is an example of the regions hook:
azs:
type: aws_azs
regions:
- us-east-1
- us-east-2
It outputs a list per this output:
{% raw %}
{{ azs }} = {% endraw %}{{ aws.azs }}
17 changes: 17 additions & 0 deletions demos/all-providers/providers/pyinquirer/checkbox.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
checkbox:
type: checkbox
choices:
- stuff
- things
message: |
This is an example of a checkbox hook. It takes in a number of options
with a list input and outputs a list.
Basic example:
type: checkbox
message: Some message...
choices:
- stuff
- things
Returns list
11 changes: 11 additions & 0 deletions demos/all-providers/providers/pyinquirer/confirm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
confirm:
type: confirm
message: |
This is an example of a basic confirm hook.
Example:
confirm:
type: confirm
message: Some message...
Returns boolean
11 changes: 11 additions & 0 deletions demos/all-providers/providers/pyinquirer/input.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
input:
type: input
default: stuff and things
message: |
This is an example of a input hook. It takes in a string.
Basic example:
type: input
message: Some message...
Returns string
16 changes: 16 additions & 0 deletions demos/all-providers/providers/pyinquirer/list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
select:
type: select
choices:
- stuff
- things
message: |
This is an example of a list hook. It takes in a list and returns on item.
Basic example:
type: input
choices:
- stuff
- things
message: Some message...
Returns string
15 changes: 15 additions & 0 deletions demos/all-providers/providers/pyinquirer/tackle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---

ops:
type: stat
input:
- confirm
- input
- list
- checkbox

hook_run:
type: tackle
template: .
context_file: "{{ item }}.yaml"
loop: "{{ ops }}"
17 changes: 17 additions & 0 deletions demos/all-providers/providers/system/command.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
command:
type: command
command: pwd

confirm_command:
type: confirm
message: |
This is an example of a command hook. It runs arbitrary system commands
and returns the value of stdout to the variable.
command:
type: command
command: pwd
It outputs a string per:
{% raw %}
{{ command }} = {% endraw %}{{ command }}
19 changes: 19 additions & 0 deletions demos/all-providers/providers/system/find_in_parent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
demos_dir:
type: find_in_parent
target: demos

confirm_command:
type: confirm
message: |
This is an example of a find_in_parent hook. It finds the absolute path
to whatever target directory that you need to find in the parent directories.
It is useful for setting absolute references to files and folders while
switching contexts in and out of other tackle boxes.
demos_dir:
type: find_in_parent
target: demos
It outputs a string per:
{% raw %}
{{ demos_dir }} = {% endraw %}{{ demos_dir }}
34 changes: 34 additions & 0 deletions demos/all-providers/providers/system/jinja.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
hold:
type: confirm
message: hold jinja

render_var:
type: var
input: 42

jinja:
type: jinja
template_path: templates/things.py.j2
output_path: testing.py

confirm:
type: path_exists
path: testing.py

confirm_jinja:
type: confirm
message: |
This is an example of a jinja hook. It renders arbitrary templates
with the context dictionary that we are building.
jinja:
type: jinja
command: pwd
It outputs a string per:
{% raw %}
{{ jinja }} = {% endraw %}{{ jinja }}
remove:
type: remove
path: testing.py
21 changes: 21 additions & 0 deletions demos/all-providers/providers/system/listdir.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
hold:
type: confirm
message: hold listdir

listdir:
type: listdir
path: .

confirm_listdir:
type: confirm
message: |
This is an example of a listdir hook. It outputs a list of files and folders
based on a given path. Has a few options per below.
listdir:
type: listdir
path: {{ cwd }} # We have special variables too!
It outputs a string per:
{% raw %}
{{ listdir }} = {% endraw %}{{ listdir }}
14 changes: 14 additions & 0 deletions demos/all-providers/providers/system/tackle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---

ops:
type: stat
input:
- command
- listdir
- jinja

hook_run:
type: tackle
template: .
context_file: "{{ item }}.yaml"
loop: "{{ ops }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = {{ render_var }}
20 changes: 20 additions & 0 deletions demos/all-providers/providers/tackle/docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXPROJ = python_boilerplate
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1 change: 1 addition & 0 deletions demos/all-providers/providers/tackle/docs/authors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. include:: ../AUTHORS.rst
Loading

0 comments on commit e11248f

Please sign in to comment.