bash-utils/awesome-tasks/.odoo/search

58 lines
1.6 KiB
Bash

#!/bin/bash
## Task odoo search v0.1.0
## Copyright (C) Thomas Di gregorio
## Licensed under MIT
##
## This task does something with the arguments.
## Usage:
## task odoo @script.name [option] PACKAGE...
##
## 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.
## -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
type=module
source easyoptions || exit
# Boolean and parameter options
[[ -n "$module" ]] && type=module
[[ -n "$theme" ]] && type=theme
echo "Search for a $type at odoo.com"
name="${arguments[0]}"
url="https://www.odoo.com/apps/${type}s/11.0/${name}/"
echo "Try $url"
wget -O $name.html $url
if [ -s $name.html ]
then
if [ -n "$no_deps" ]
then
grep -o "https://apps.odoo.com/loempia/download/.*?deps" $name.html | sed 's/?deps//g' > $name.url
else
grep -o "https://apps.odoo.com/loempia/download/.*?deps" $name.html > $name.url
fi
wget -O $name.zip "$(cat $name.url)"
unzip -l $name.zip "*/__init__.py" -x "*/*/*" | grep -o "[A-Z1-9a-z_]*/" | sed 's|/||' > $name.package
unzip $name.zip
else
echo "Not found any $type"
fi