-
Notifications
You must be signed in to change notification settings - Fork 1
/
pallet2jack
executable file
·59 lines (52 loc) · 1.16 KB
/
pallet2jack
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
#!/bin/bash
set -eu -o pipefail
function help () {
echo "$(basename ${0}): Determine the jack from a pallet identifier"
echo
echo "Usage: $(basename ${0}) <warehouse> <pallet> <jack>"
echo
}
SELF_DIR=$(cd $(dirname ${0}) && pwd -P)
SELF=${SELF_DIR}/$(basename ${0})
. ${SELF_DIR}/source.bash
args_min 1
WAREHOUSE="${1}"
case ${WAREHOUSE} in
-h|--help)
help
exit 0
;;
esac
args_eq 3
PALLET="${2}"
VERSION="${3}"
shift 3
case ${WAREHOUSE} in
builtin)
echo "builtin"
;;
com.github)
echo "github"
;;
org.maven)
echo "maven"
;;
*)
pushd ${SELF_DIR} > /dev/null 2>&1
echo -e "${CFMT_INFO}Searching for jacks for pallet ${WAREHOUSE} ${PALLET} ${VERSION}${CFMT_NORMAL}" >&2
JACKFILE=$(mktemp)
set +e
${SELF_DIR}/../cache/cache ${SELF_DIR}/findjacks ${WAREHOUSE} ${PALLET} ${VERSION} > ${JACKFILE}
set -e
if [ ! -f ${JACKFILE} ]; then
fail "Could not find suitable jack for pallet (couldn't even search for jacks)"
fi
JACKCOUNT=$(wc -l ${JACKFILE} | cut -f 1 -d ' ')
if [[ ${JACKCOUNT} -ne 1 ]]; then
fail "Could not find suitable jack for pallet (found ${JACKCOUNT} jacks)"
fi
cat ${JACKFILE}
rm ${JACKFILE}
popd > /dev/null 2>&1
;;
esac