Verified Commit 10bc7a27 authored by Marco Kellershoff's avatar Marco Kellershoff 🤸

Update example Taskfile

parent facf0518
#!/bin/bash
# Helper functions start with _ and are invisible to bash auto completion.
function _get_random_number {
local min=$1
local max=$2
echo $(( ( RANDOM % $max ) + $min ))
}
# This is just an example
function build {
echo "This serves as an super evil example."
sleep 2
local foo=0
echo -ne "Doing stuff ..."
while [ $foo -lt 10 ]; do
local rand=$(_get_random_number 1 10)
local i=0
echo
echo "Build $1"
while [ $i -lt $rand ]; do
sleep 1
echo -ne "."
((foo++))
echo -ne "\tComputing $1 ...\n"
((i++))
done
echo ""
}
function listfiles {
ls
echo "Finished $1"
echo
}
function listallfiles {
ls -la
}
function tasks {
compgen -A function
# Parallelisation - run multiple tasks in parallel.
function build-all {
build android & build iphone & build ipad & build web &
wait
}
# Another example, but it's always a good practice to have a help function
function help {
echo "$0 <task> <args>"
echo "Tasks:"
tasks | cat -n
}
# This task needs to left as it is
# This is for external plugins and programs to query the available tasks
function tasks {
compgen -A function | grep -v "^_"
}
# This is a wrapper for what should be executed, when no args are passed to the
# Taskfile
function default {
tasks
}
${@:-tasks}
${@:-default}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment