Skip to content
Snippets Groups Projects
Commit a270b7f3 authored by alangrafu's avatar alangrafu
Browse files

Merge branch 'master' of https://github.com/alangrafu/lodspeakr

parents dbdd6475 4aeb23ca
No related branches found
No related tags found
No related merge requests found
#!/bin/bash #!/bin/bash
#
# https://github.com/alangrafu/lodspeakr/blob/master/utils/ldspk.sh
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
USAGE="Usage: $0 create|delete uri|class|service foo [html|rdf|ttl|nt|json]" USAGE="Usage: $0 create|delete uri|class|service foo [html|rdf|ttl|nt|json]"
formats=( html rdf ttl nt json all ) if [[ $# -eq 0 || "$1" == "--help" ]]; then
echo $USAGE
exit 1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
operations=( create delete ) operations=( create delete )
modules=( class service uri ) modules=( class service uri )
formats=( html rdf ttl nt json all )
currentOperation= currentOperation=
currentFormat=
currentModule= currentModule=
currentFormat=
if [[ ${operations[@]} =~ $1 ]] if [[ ${operations[@]} =~ $1 ]]; then
then
currentOperation=$1 currentOperation=$1
else else
echo "Operation \"$1\" not valid" echo "Operation \"$1\" not valid"
...@@ -19,8 +25,7 @@ else ...@@ -19,8 +25,7 @@ else
exit 1 exit 1
fi fi
if [[ ${modules[@]} =~ $2 ]] if [[ ${modules[@]} =~ $2 ]]; then
then
currentModule=$2 currentModule=$2
else else
echo "Module \"$2\" not valid" echo "Module \"$2\" not valid"
...@@ -28,31 +33,23 @@ else ...@@ -28,31 +33,23 @@ else
exit 1 exit 1
fi fi
if [[ ${formats[@]} =~ $4 ]] currentUnit=$3
then
if [[ ${formats[@]} =~ $4 ]]; then
currentFormat=$4 currentFormat=$4
else else
if [ -z "$4" ] if [ -z "$4" ]; then
then
currentFormat="all" currentFormat="all"
else else
echo "Format \"$4\" not valid" echo "Format \"$4\" not valid"
echo $USAGE echo $USAGE
exit 1 exit 1
fi fi
fi fi
if [[ $currentOperation == "create" ]]; then
currentUnit=$3
if [[ $currentOperation == "create" ]]
then
$DIR/modules/create-$currentModule.sh "$currentUnit" "$currentFormat" $DIR/modules/create-$currentModule.sh "$currentUnit" "$currentFormat"
fi fi
if [[ $currentOperation == "delete" ]] if [[ $currentOperation == "delete" ]]; then
then
$DIR/modules/delete-$currentModule.sh "$currentUnit" "$currentFormat" $DIR/modules/delete-$currentModule.sh "$currentUnit" "$currentFormat"
fi fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment