|
| 1 | +#!/bin/bash |
| 2 | +############################## DEV_SCRIPT_MARKER ############################## |
| 3 | +# This script is used to document and run recurring tasks in development. # |
| 4 | +# # |
| 5 | +# You can run your tasks using the script `./dev some-task`. # |
| 6 | +# You can install the Sandstorm Dev Script Runner and run your tasks from any # |
| 7 | +# nested folder using `dev some-task`. # |
| 8 | +# https://github.com/sandstorm/Sandstorm.DevScriptRunner # |
| 9 | +############################################################################### |
| 10 | + |
| 11 | +set -e |
| 12 | + |
| 13 | +######### TASKS ######### |
| 14 | + |
| 15 | +# easy setup of the project |
| 16 | +function setup() { |
| 17 | + # As the setup typically is more complex we recommend using a separate shell script |
| 18 | + ./dev_setup.sh |
| 19 | +} |
| 20 | + |
| 21 | +# sometask to help with something |
| 22 | +# |
| 23 | +# The first line of the comment will we used in the task overview. |
| 24 | +# If you want to provide more details just add more lines ;) |
| 25 | +function sometask() { |
| 26 | + # Most task will only require some steps. We recommend implementing them here |
| 27 | + _log_success "Some task" |
| 28 | + _log_warning "TODO: implement more steps" |
| 29 | +} |
| 30 | + |
| 31 | +# another task to help with something else |
| 32 | +# |
| 33 | +# The first line of the comment will we used in the task overview. |
| 34 | +# If you want to provide more details just add more lines ;) |
| 35 | +function taskwitharguments() { |
| 36 | + # You can access arguments using $@ array. The task name will not be part of the array |
| 37 | + _log_success "Task with arguments" |
| 38 | + _log_warning "TODO: implement more steps" |
| 39 | + _log_success "Arguments" |
| 40 | + _log_success ' $0: '"$0" |
| 41 | + _log_success ' $1: '"$1" |
| 42 | + _log_success ' $2: '"$2" |
| 43 | +} |
| 44 | + |
| 45 | +####### Utilities ####### |
| 46 | + |
| 47 | +_log_success() { |
| 48 | + printf "\033[0;32m%s\033[0m\n" "${1}" |
| 49 | +} |
| 50 | +_log_warning() { |
| 51 | + printf "\033[1;33m%s\033[0m\n" "${1}" |
| 52 | +} |
| 53 | +_log_error() { |
| 54 | + printf "\033[0;31m%s\033[0m\n" "${1}" |
| 55 | +} |
| 56 | + |
| 57 | +# THIS NEEDS TO BE LAST!!! |
| 58 | +# this will run your tasks |
| 59 | +"$@" |
0 commit comments