Quickstart¶
In a typical workflow, Bakefile lives in the root directory of your project and you should be running bake command from the same directory. Bakefiles contain information regarding the tasks that you want to accomplish. A task is basically an assortment of bash commands which can be anything from a simple one liner to a uber complicated hierarchical workflow with multiple subtasks. Each task has to follow a specific structure.
Bake is space aware. Use four spaces to indent in the appropriate positions.
Task without Subtasks¶
Here is a simple example of a Bakefile containing a single task.
# Bakefile
task1:
# print a Rambrant quote
echo "“Painting is the grandchild of Nature.”
― Rembrandt Van Rijn"
To run this task, type:
bake task1
You terminal should print something like this:
+ Executing task1:
| “Painting is the grandchild of Nature.”
| ― Rembrandt Van Rijn
+ Done.
Task with Subtasks¶
Subtasks can be defined via task/subtask format. You can also use task//subtask format to define subtasks. For example:
# Bakefile
# task with subtasks
task2: task2/subtask1 task2//subtask2
# subtasks
task2/subtask1:
# print a Vinci quote
echo "“Nothing strengthens authority so much as silence.”
- Leonardo Da Vinci"
task2//subtask2:
# print a Gogh quote
echo "“Art is to console those who are broken by life.”
- Vincent van Gogh"
You can choose to run individual subtasks or all the tasks at the same time. To run a subtask, run:
bake task2/subtask1
+ Executing task2/subtask1:
| “Nothing strengthens authority so much as silence.”
| - Leonardo Da Vinci
+ Done.
Or you can run all the subtasks simultaneously by calling the primary task. To all subtasks under task2, run:
+ Executing task2/subtask1:
| “Nothing strengthens authority so much as silence.”
| - Leonardo Da Vinci
+ Executing task2//subtask2:
| “Art is to console those who are broken by life.”
| - Vincent van Gogh
+ Executing task2:
+ Done.
Task with Arguments¶
Arguments can be easily passed to the task in bake taskname arg1 arg2 … format
# Bakefile
# task with argument
task3/subtask1:
# take any number of integers and return their sum
num1=$1
num2=$2
((sum=num1 + num2))
echo "Sum of $1 & $2 is $sum"
Run the task via:
bake task3/subtask1 1 2
You should see the output in the terminal:
+ Executing task3/subtask1:
| Sum of 1 & 2 is 3
+ Done.
Task with Confirmation Prompt¶
You can fire a confirmation prompt before running a task using taskname:@confirm format.
# Bakefile
# task with confirmation prompt
task4/subtask1:@confirm
echo "Performing ls command..."
echo ""
echo "Files in your current folder:"
ls
The output should be (depends where you run the command):
? Do you want to continue? [y/N]: y
+ Executing task4/subtask1:
| Performing ls command
|
| Files in your current folder:
| Bakefile
| faqs.md
| installation.md
| quickstart.md
+ Done.