Primo abbozzo. Ancora molta strada da fare
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
#! /bin/bash --
|
||||
[ ! -z "${GREZZO_1577142078}" ] && return; GREZZO_1577142078=0
|
||||
unset CDPATH
|
||||
DOVE="$(cd "$(dirname "$(readlink -f -- "${BASH_SOURCE[0]}")")" > /dev/null && pwd -P)"
|
||||
|
||||
. "$DOVE/pip.sh"
|
||||
|
||||
function feat_add_poetry() {
|
||||
feat_needed "pip"
|
||||
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
|
||||
. "$HOME/.poetry/env"
|
||||
}
|
||||
|
||||
function poetry_initialized() {
|
||||
poetry check >/dev/null 2>&1
|
||||
}
|
||||
|
||||
function poetry_feat_added() {
|
||||
poetry show | cut -f1 -d ' ' | grep -q ^"$1"$
|
||||
}
|
||||
|
||||
function poetry_feat_missing() {
|
||||
if feat_missing "pip"; then
|
||||
true
|
||||
else
|
||||
if feat_missing "poetry"; then
|
||||
true
|
||||
else
|
||||
if ! poetry_initialized; then
|
||||
true
|
||||
fi
|
||||
! poetry run python -c "import $1" >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function poetry_feat_needed() {
|
||||
feat_needed "poetry"
|
||||
FEAT="$1"
|
||||
if ! poetry_initialized; then
|
||||
poetry init
|
||||
fi
|
||||
if poetry_feat_added "$FEAT"; then
|
||||
if poetry_feat_missing "$FEAT"; then
|
||||
poetry install
|
||||
fi
|
||||
else
|
||||
if type "poetry_feat_add_$FEAT" > /dev/null 2>&1 ; then
|
||||
eval "poetry_feat_add_$FEAT"
|
||||
else
|
||||
poetry_feat_add "$FEAT"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function poetry_feat_add() {
|
||||
poetry add "$1"
|
||||
}
|
||||
|
||||
unset DOVE
|
||||
Reference in New Issue
Block a user