69 lines
1.7 KiB
Plaintext
69 lines
1.7 KiB
Plaintext
|
|
||
|
#!/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}
|