#!/bin/bash

[ -r ../env ] && . ../env
[ -r env ] && . ./env

[ -z "$INSTALL_FILE" ] && echo "Check env values && exit 1
[ -z "$INSTALL_BIN_PATH" ] && echo "Check env values && exit 1

echo "------------------------------"
echo "Install nu plugins in $INSTALL_BIN_PATH ..."
echo "------------------------------"
[ -r nu ] &&  cp -v nu $INSTALL_BIN_PATH
cp -pv nu_plugin* $INSTALL_BIN_PATH

if [ -x "$INSTALL_FILE" ] ; then 
   echo "------------------------------"
   echo "To add plugins to Nushell run: "
   echo "./$INSTALL_FILE"
fi
if [ -x "./kcl-install.sh" ] ; then 
   echo "------------------------------"
   echo "Install KCL for nu_plugin_kcl as CLI wrapper "
   ./kcl-install.sh
fi

