script testé est fonctionnel
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
d524798969
commit
9d2e58def4
@ -1,32 +1,34 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
for i in seq 0 $# ; do
|
|
||||||
echo "argument $i = $*[i]"
|
|
||||||
exit
|
|
||||||
done
|
|
||||||
|
|
||||||
if test "$1" = "--help" && test "$2" = "" ; then
|
if test "$1" = "--help" && test "$2" = "" ; then
|
||||||
cat << EOF
|
cat << EOF
|
||||||
param 1 : name of the fake datas json file to convert
|
param 1 : name of the fake datas json file to convert
|
||||||
param 2 : name of class this is for
|
param 2 : name of class this is for
|
||||||
param 3 : name of the repertorie with all C# fake datas files
|
(param 3 : name of the repertorie with all C# fake datas files)
|
||||||
EOF
|
EOF
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$1" = "" || test "$2" = "" || test "$3" = "" ; then
|
if test $# -lt 2 ; then
|
||||||
echo "error : param require" >2
|
echo "error : param require" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
count=$( echo $1 | tr "." "\n" | wc -l )
|
count=$( echo $1 | tr "." "\n" | wc -l )
|
||||||
name=$( echo $1 | cut -d ' ' -f -$(( $count - 1 )) )
|
name=$( echo $1 | cut -d '.' -f -$(( $count - 1 )) )
|
||||||
target=$( echo "$3/$1" | sed "s/json$/cs/" )
|
if test "$3" != "" ; then
|
||||||
|
target=$( echo "$3/$name.cs" )
|
||||||
|
else
|
||||||
|
target=$( echo "$name.cs" )
|
||||||
|
fi
|
||||||
|
|
||||||
echo "name : $name"
|
if test "$3" != "" ; then
|
||||||
echo "target : $target"
|
if ! ls | egrep -q "^$3$" ; then
|
||||||
|
mkdir -p $3
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
cat fake-Answers.json | sed 's/:/ =/g' \
|
cat fake-Answers.json | sed 's/:/ =/g' \
|
||||||
| sed 's/{/new AnswerEntity{/g' | sed 's/]/} ;/g' \
|
| sed "s/{/new $2{/g" | sed "s/]/} ;/g" \
|
||||||
| sed 's/\[/IEnumerable<AnswerEntity> fakeAnswers = new List<AnswerEntity>\{/g' \
|
| sed "s/\[/IEnumerable<$2> $name = new List<$2>\{/g" \
|
||||||
| sed "s/ \"/ /g" | sed 's/" =/ =/g'
|
| sed 's/ \"/ /g' | sed 's/" =/ =/g' >$target
|
||||||
|
Loading…
Reference in new issue