-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathiati-data-validator
More file actions
executable file
·87 lines (70 loc) · 2.32 KB
/
iati-data-validator
File metadata and controls
executable file
·87 lines (70 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
iati_engine=$(basename ${BASH_SOURCE[0]})
case "$1." in
"-?.")
cat <<EOT
$iati_engine
-? Show this help text.
(without parameters) Shows the available 'targets' the engine can create.
-p Idem.
autocompletion Add command-line autocompletion to your current
shell. Run this command, including the leading dot:
. $iati_engine autocompletion
EOT
;;
"autocompletion." )
# When running as a 'dot command' $0 points to the shell, not to our script
if [[ `basename $0` != 'bash' ]]
then
echo -e "\nMake sure to include the dot before the command to enable autocompletion:"
echo "Run '. $iati_engine autocompletion'"
else
# add command line autocompletion:
export _iati_data_validator_targets=`$iati_engine -p -q | grep ^\ | cut -f 2 -d \ `
_iati_data_validator()
{
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case "${prev}" in
show|val-act|val-org)
_filedir
return 0
;;
*)
;;
esac
COMPREPLY=( $(compgen -W "${_iati_data_validator_targets}" -- ${cur}) )
}
complete -F _iati_data_validator $iati_engine
echo -e "\nCommand-line autocompletion added for $iati_engine"
fi
;;
*)
# Run a Docker container with the image
if [ "${_iati_data_validator_targets}." = "." ]; then
echo -e "\nTIP: Run '. $(basename $0) autocompletion' to add command-line autocompletion in your shell.\n"
fi
# Run the engine using our own user and group id's so we can manage the results
USER=`id -u`:`id -g`
PARAMETERS=$@
# Use the local code of the engine if available
MY_PATH=$(dirname `readlink -f "$0"`)
WORKSPACE=`pwd`
if [ "$1." != "webhook." ]; then
ENTRY="--entrypoint=/opt/ant/bin/ant"
PARAMETERS="-e -f build-engine.xml ${@:--p}"
fi
if [[ -f ${MY_PATH}/helpers/engine-start ]]; then
. ${MY_PATH}/helpers/engine-start
fi
docker run --rm -u=${USER} \
-v $WORKSPACE:/workspace \
-p 9000:9000 \
-m 3g \
$OTHER_VOLUMES \
$ENTRY \
iati-data-validator $PARAMETERS
;;
esac