taste-create-acn-model 1.14 KB
Newer Older
1
#!/bin/bash -e
Maxime Perrotin's avatar
Maxime Perrotin committed
2 3 4

# TASTE ACN File creator

5
if [ -t 1 ] ; then
Maxime Perrotin's avatar
Maxime Perrotin committed
6 7 8 9 10 11 12 13
    COLORON="\e[1m\e[32m"
    REDCOLORON="\e[1m\e[31m"
    COLOROFF="\e[0m"
else
    COLORON=""
    REDCOLORON=""
    COLOROFF=""
fi
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

DATAVIEW=DataView.asn

if [ ! -z $(which kate) ]
then
    EDITOR="kate -n"
elif [ ! -z $(which gvim) ]
then
    EDITOR="gvim -f"
else
    EDITOR=vi
fi

if [ ! -z "$1" ]
then
    if [ -f "$1" ]
    then
        DATAVIEW="$1"
    else
Maxime Perrotin's avatar
Maxime Perrotin committed
33 34
        echo -e -n "${ERROR} Invalid dataview filename - "
        echo use $(basename "$0") \<filename.asn\>
35 36 37 38 39 40
        exit -1
    fi
fi

if [ -f "$DATAVIEW" ]
then 
Maxime Perrotin's avatar
Maxime Perrotin committed
41
    echo -e "${INFO} Creating dummy ACN file from existing DataView.asn"
42
else
Maxime Perrotin's avatar
Maxime Perrotin committed
43
    echo -e "${INFO} First create your ASN.1 data model: run taste-create-data-view"
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
    exit -1
fi

TASTE_TYPES=$(taste-config --prefix)/share/taste-types/taste-types.asn
mono $(which asn1.exe) -ACND "$DATAVIEW" "$TASTE_TYPES"

ACNFILENAME=${DATAVIEW%.*}.acn

if [ -z $NONINTERACTIVE ]
then
    $EDITOR "$ACNFILENAME"
fi

taste-update-data-view $1

Maxime Perrotin's avatar
Maxime Perrotin committed
59 60 61 62 63
if [ -z $NONINTERACTIVE ]
then
    echo -e "${INFO} All OK"
    echo -e "${INFO} If you want to edit your ACN model, run taste-edit-acn-model"
fi