From e81b207cbe025c107f26d5689496fe76affba810 Mon Sep 17 00:00:00 2001 From: dig Date: Mon, 21 May 2018 19:54:57 +0200 Subject: [PATCH] First commit --- tasks/task | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 tasks/task diff --git a/tasks/task b/tasks/task new file mode 100644 index 0000000..e685978 --- /dev/null +++ b/tasks/task @@ -0,0 +1,68 @@ + +#!/bin/bash + +## Task v0.1.0 +## Copyright (C) Thomas Di gregorio +## Licensed under MIT (should be GPL because of easyoptions?) +## +## Launch a task in the current working dir's .task folder. +## Or create a new task chmoded u+x in current working dir's .task folder +## ( .tasks folder is created if not present ). +## Usage: +## @script.name [-c NAME [NAMES]] | TASK ARGUMENTS... +## +## 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. +## -c, --create Search a module (default) on odoo.com website. +## +## Exemples: +## task --create foo +## task -c foo --sub-tasks=bar,baz +## task foo --help +## task foo bar --option arg1 arg2 -c +## task foo help bar + +# defaults ex: (uncomment) +#option1=coucou + +source easyoptions || exit +verbose() { [[ -n "$verbose" ]] && echo $1; } + + + +create() +{ + # Test if .tasks folder exists first and create it + [[ ! -d "$PWD/.tasks" ]] && mkdir $PWD/.tasks && verbose "Missing .tasks/ folder,... created !" + # TODO then the same for sub-tasks + + TASK_PATH=$PWD/.tasks/$1 + + TASK_NAME=$1 .taskrc > $TASK_PATH + + chmod u+x $TASK_PATH + nano $TASK_PATH + exit; +} + + +if [ -n "$verbose" ] +then + # Arguments + for argument in "${arguments[@]}"; do + echo "Argument specified: $argument" + done +fi + + +[[ -n "$create" ]] && create ${arguments[@]} + + + +################################################################################ + +# Calls command (1rt argument) as function \$1( \$2 \$3 ... ) +$PWD/.tasks/$1 ${@:2}