#!/usr/bin/bash
# -*- sh; sh-shell: bash; -*-

# Script to remove all linphone contacts

# Script Requires: bash tar xz sed sqlite3 regexp.so
# regexp.so for linux x86 is inside archive https://github.com/nalgeon/sqlean/releases/download/0.21.8/sqlean-linux-x86.zip
# https://hakanu.net/sqlite/2021/04/10/how-to-achieve-regular-expression-based-replace-in-sqlite-regex/
# https://github.com/nalgeon/sqlean/blob/main/docs/regexp.md

# Tested with linphone v5.2.0

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $SCRIPT_DIR/linphone-contacts-library

echo 'To reveal all linphone contacts manipulation tools,'
echo 'type the following command in terminal:'
echo
echo "    source $SCRIPT_DIR/linphone-contacts-library"
echo
#sleep 1
echo 'Then type in terminal:'
#sleep 1
echo
echo '    linphone-'
echo
echo '        Press <TAB> <TAB> <TAB> three times'
echo
#sleep 1
echo 'or type in terminal:'
echo
#echo "    cat $SCRIPT_DIR/linphone-contacts-library | grep linphone-contacts | sed 's/function //g' | sed 's/python3.*//g' | sed 's/{//g' | sed 's/#.*//g' | tr -d ' ' | sed '/^[[:space:]]*$/d' | sort | uniq"
echo "    THISDIR=\$(pwd); SCRIPT_DIR=$SCRIPT_DIR; source \$SCRIPT_DIR/linphone-contacts-library; cd \$SCRIPT_DIR; echo; ls -1 linphone-*; cat \$SCRIPT_DIR/linphone-contacts-library | grep linphone-contacts | sed 's/function //g' | sed 's/python3.*//g' | sed 's/{//g' | sed 's/#.*//g' | tr -d ' ' | sed '/^[[:space:]]*$/d' | sort | uniq; cd \$THISDIR;"
echo

exit 0
