2018-05-21 19:54:57 +02:00
|
|
|
|
|
|
|
#!/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
|
|
|
|
|
2018-07-02 23:01:21 +02:00
|
|
|
#source easyoptions || exit
|
|
|
|
#verbose() { [[ -n "$verbose" ]] && echo $1; }
|
2018-05-21 19:54:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-02 23:01:21 +02:00
|
|
|
# Boolean and parameter options
|
|
|
|
[[ $1 == "--create" ]] && create ${@:2}
|
|
|
|
[[ $1 == "-c" ]] && create ${@:2}
|
2018-05-21 19:54:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
2018-07-02 23:01:21 +02:00
|
|
|
# Calls command (1rt argument) as function $1( $2 $3 ... )
|
2018-05-21 19:54:57 +02:00
|
|
|
$PWD/.tasks/$1 ${@:2}
|