#!/usr/bin/env bash
VERSION=0.6r11
DEST=$1
shift 1
ORIG=$@

if [[ -e  ./lib/resources.sh ]]; then . ./lib/resources.sh; else . /usr/lib/lch/resources.sh; fi
if [[ -e  ./lib/compressor.sh ]]; then . ./lib/compressor.sh; else . /usr/lib/lch/compressor.sh; fi
if [[ -e  ./lib/decompressor.sh ]]; then . ./lib/decompressor.sh; else . /usr/lib/lch/decompressor.sh; fi
if [[ -e  ./lib/installer.sh ]]; then . ./lib/installer.sh; else . /usr/lib/lch/installer.sh; fi

if [ "$DEST" = "--version" ] || [ "$DEST" = "-v" ]
then
    echo "Linux Compression Humanized $VERSION"
    exit 0
else
    echo -e "\nlch $VERSION"
    echo -e "---------\n"

    case $DEST in
        "--help" | "-h")
            help
        ;;
        "--check" | "-c")
            check
        ;;
        "--install" | "-i")
            install $DEST $@
        ;;
        *)
            if [ -z "$DEST" ]
            then
                help
                exit 1
            else
                if [ -n "$ORIG" ]
                then
                    echo "Compressor:"
                    echo  -e "-----------\n"
                    compressor $DEST $ORIG
                else
                    echo "Decompressor:"
                    echo -e "-------------\n"
                    decompressor $DEST
                fi
            fi
        ;;
    esac
    exit 0
fi