#!/bin/bash
# Title:
# Version:
# Author: Frédéric CHEVALIER <fcheval@txbiomedgenetics.org>
# Created in: 2014-1
# Modified in:
# Licence : GPL v3
#======#
# Aims #
#======#
#
#==========#
# Versions #
#==========#
# v0.0 - 2014-1: creation
#===========#
# Functions #
#===========#
# Dependency test
function test_dep {
which $1 &> /dev/null
if [[ $? != 0 ]]
then
error "Package $1 is needed. Exiting..." 1
fi
}
# Usage message
function usage {
echo -e "
\e[32m ${0##*/} \e[00m -i|--in file -o|--out value -v|--val value -s|--switch -h|--help
Options:
-i, --in input file
-o, --out name of output file
-v, --val value
-s, --switch switch
-h, --help this message
"
}
# Info message
function info {
if [[ -t 1 ]]
then
echo -e "\e[32mInfo:\e[00m $1"
else
echo -e "Info: $1"
fi
}
# Warning message
function warning {
if [[ -t 1 ]]
then
echo -e "\e[33mWarning:\e[00m $1"
else
echo -e "Warning: $1"
fi
}
# Error message
function error {
if [[ -t 1 ]]
then
echo -e "\e[31mError:\e[00m $1"
exit $2
else
echo -e "Error: $1"
exit $2
fi
}
#==============#
# Dependencies #
#==============#
#
#==========================#
# Declaration of variables #
#==========================#
# Load variables
while [[ $# -gt 0 ]]
do
case $1 in
-i|--in ) input="$2" ; shift 2
while [[ ! -z "$1" && $(echo "$1"\ | grep -qv "^-" ; echo $?) == 0 ]]
do
input=$(echo "$input" "$1")
shift
done ;;
-o|--out ) output="$2" ; shift 2 ;;
-v|--val ) v="$2" ; shift 2 ;;
-s|--switch ) switch=1 ; shift ;;
-h|--help ) usage ; exit 0 ;;
* ) error "Invalid option: $1\n$(usage)" 1 ;;
esac
done
# Check the existence of obligatory options
if [[ -z "$input" ]]
then
error "The option input is required. Exiting...\n$(usage)" 1
fi
if [[ -z "$output" ]]
then
output=
fi
#============#
# Processing #
#============#
exit 0