#!/bin/bash
# Title:
# Version:
# Author: Frédéric CHEVALIER <fcheval@txbiomedgenetics.org>
# Created in: 2014-0
# Modified in:
# Licence : GPL v3
#======#
# Aims #
#======#
#
#==========#
# Versions #
#==========#
# v0.0: creation
#==============#
# Dependencies #
#==============#
#
#===========#
# Functions #
#===========#
# 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
"
}
# Error message
function error {
echo -e "\e[31mError:\e[00m $1"
exit $2
}
# Warning message
function warning {
echo -e "\e[33mWarning:\e[00m $1"
}
#==========================#
# 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 ;;
* ) echo "Invalid option: $1"
usage
exit 1 ;;
esac
done
# Check the existence of obligatory options
if [[ -z "$input" ]]
then
error "The option input is required. Exiting..." 1
fi
if [[ -z "$output" ]]
then
output=
fi
#============#
# Processing #
#============#
exit 0