#!/home/dig/bin/shtpl #!/bin/bash $(read -r -p Need\ some\ infos\ for\ task\ $TASK_NAME\ \(\ \hit\ enter\ \)\ v) ## ## Task $TASK_NAME v$(read -r -p Version?\ v;echo $v) ## Copyright (C) $(read -r -p Author?\ v;echo $v) ## Licensed under $(read -r -p Licensed\ under?\ v;echo $v) ## ## $(read -r -p What\'s\ used\ for? v;echo $v) ## ## Usage: ## @script.name $(read -r -p Usage:\ $TASK_NAME\ v;echo $v) ## ## Options: ## ( Long version are mandatory, and can be before or after short version ) ## ## -h, --help Show this help. ## -v, --verbose Show sub-task resolution and options parsed. ## ## ## Exemples: ## ## # write your default options here source easyoptions || exit verbose() { [[ -n "\$verbose" ]] && echo \$1; } ##### YOUR CODE HERE ##### ##### SNIPPETS ################################################################## # Boolean and parameter options # [[ -n "\$option" ]] && echo "Option specified: --option is \$option" # Arguments #for argument in "\${arguments[@]}"; do # echo "Argument specified: \$argument" #done # Verbose (echo only if -v or --verbose options #verbose "I\'m doing things" #mkdir "cant/create/this" || verbose "Error creating folder!" # Auto called function acording to 1st agument #command() #{ # # here get 2nd argument with $1 (local 1st arg) or ${arguments[2]} (script) #} ################################################################################ __dirname="\$(dirname \$0)" __dirtask="\$__dirname/.\$(basename \$0)" __taskargs=\$(echo "\${@:1}" | sed "s/\${arguments[0]} //") # Calls command (1rt argument) as script or function \$1( \$2 \$3 ... ) if [ -r "\$__dirtask/\${arguments[0]}" ] then verbose "Command file exists call it: \$__dirtask/\${arguments[0]} \$__taskargs" \$__dirtask/\${arguments[0]} \$__taskargs else if [ -n "\$(type -t \${arguments[0]})" ] && [ "\$(type -t \${arguments[0]})" = function ]; then verbose "\$__dirtask/\${arguments[0]} do not exists, trying function: \${arguments[0]} \$__taskargs" \${arguments[0]} \$__taskargs fi fi