bash-utils/awesome-tasks/odoo

78 lines
2.3 KiB
Plaintext
Raw Normal View History

2018-05-21 20:41:19 +02:00
#!/bin/bash
## Task odoo v1.0
## Copyright (C) Thomas Di gregorio
## Licensed under MIT
##
## This task does something with the arguments.
## Usage:
## task @script.name COMMAND [option] PACKAGE...
##
## Commands:
## help COMMAND Shows the command's help.
## search e
## download | dl e
## install e
##
## 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.
## -m, --module Search a module (default) on odoo.com website.
## -t, --theme Search a theme on odoo.com website.
## -z, --unzip Unzip the downloaded package.
## --in=VALUE Defines the docker dir of odoo addons to install the package in.
2018-07-03 00:11:18 +02:00
## -n, --no-deps Download without dependencies.
2018-05-21 20:41:19 +02:00
##
## Exemples:
## task odoo search web_responsive
## task odoo search --module web_responsive
## task odoo search -m web_responsive
## task odoo search --theme awesome_theme
## task odoo search -t awesome_theme
## task odoo dl -t awesome_theme --unzip
## task odoo dl web_responsive -z
## task odoo install awesome_theme --in odoo-test
## task odoo help COMMAND
##
2018-07-03 00:11:18 +02:00
# write your default options here
2018-05-21 20:41:19 +02:00
source easyoptions || exit
verbose() { [[ -n "$verbose" ]] && echo $1; }
##### YOUR CODE HERE #####
help()
{
verbose "HELP: $@"
$__dirtask/$1 --help
}
dl()
{
$__dirtask/download $@
}
2018-07-03 00:11:18 +02:00
2018-05-21 20:41:19 +02:00
################################################################################
__dirname="$(dirname $0)"
__dirtask="$__dirname/.$(basename $0)"
2018-07-03 00:11:18 +02:00
__taskargs=$(echo "${@:1}" | sed "s/${arguments[0]} //")
2018-05-21 20:41:19 +02:00
2018-07-03 00:11:18 +02:00
# 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
2018-05-21 20:41:19 +02:00
else
2018-07-03 00:11:18 +02:00
if [ -n "$(type -t ${arguments[0]})" ] && [ "$(type -t ${arguments[0]})" = function ];
2018-05-21 20:41:19 +02:00
then
2018-07-03 00:11:18 +02:00
verbose "$__dirtask/${arguments[0]} do not exists, trying function: ${arguments[0]} $__taskargs"
${arguments[0]} $__taskargs
2018-05-21 20:41:19 +02:00
fi
fi