78 lines
2.3 KiB
Bash
78 lines
2.3 KiB
Bash
#!/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.
|
|
## -n, --no-deps Download without dependencies.
|
|
##
|
|
## 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
|
|
##
|
|
|
|
# write your default options here
|
|
|
|
source easyoptions || exit
|
|
verbose() { [[ -n "$verbose" ]] && echo $1; }
|
|
|
|
##### YOUR CODE HERE #####
|
|
|
|
|
|
help()
|
|
{
|
|
verbose "HELP: $@"
|
|
$__dirtask/$1 --help
|
|
}
|
|
|
|
dl()
|
|
{
|
|
$__dirtask/download $@
|
|
}
|
|
|
|
|
|
|
|
################################################################################
|
|
__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
|