Files
git.taskfile.build/README.md
T

14 KiB

layout, permalink
layout permalink
layouts/base.njk /

task

Run any project.

The task file is a simple bash script and standardized interface for all software projects.

It is to be understood as a software development pattern to standardize the installation, configuration and execution of different software frameworks.

Specification

The specification is a short guide to setting up a task file for a Python project.

  • Create a file task in your project.
touch task
  • Ensure it is executable.
chmod +x task
  • First add the bash shebang.
#!/bin/bash
  • Then append the abort on error setting.
set -e
  • Load environment variables from the .env file.
if [[ -a ".env" ]]; then
    source .env
fi
  • Add a help function.
function help() {
    echo
    echo "task <command> [options]"
    echo
    echo "commands:"
    echo

    # Define column widths
    CMD_WIDTH=10
    OPT_WIDTH=6
    DESC_WIDTH=40
    COLUMN="| %-${CMD_WIDTH}s | %-${OPT_WIDTH}s | %-${DESC_WIDTH}s |\n"

    # Print table header
    printf "$COLUMN" "Command" "Option" "Description"
    echo "|$(printf '%*s' $((CMD_WIDTH + 2)) '' | tr ' ' '-')|$(printf '%*s' $((OPT_WIDTH + 2)) '' | tr ' ' '-')|$(printf '%*s' $((DESC_WIDTH + 2)) '' | tr ' ' '-')|"

    # Print table rows

    printf "$COLUMN" "all" "" "Run all tasks."
    printf "$COLUMN" "install" "&