-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsstd
executable file
·50 lines (45 loc) · 1.24 KB
/
sstd
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
#!/usr/bin/env bash
tool=$(echo ${1:-"help"} | tr '[:upper:]' '[:lower:]')
paths=()
bases=()
getfiles () {
if [ $1 -ne $(expr $BASH_ARGC - 1) ]; then
if [ $1 -eq 1 ]; then
sing_plur="argument"
else
sing_plur="arguments"
fi
echo Expected $1 $sing_plur, not $(expr $BASH_ARGC - 1).
exit 1
fi
for ((i=1; i<=$1; i++))
do
file=${BASH_ARGV[$1-$i]}
if [ ! -f $file ]; then
echo File $file not found.
exit 1
fi
path=($(realpath $file))
paths+=($path)
bases+=($(basename $path))
done
}
case $tool in
txt)
getfiles 1
docker run --name sstd -v "${paths[0]}":/tmp/"${bases[0]}" jonathanhuston/slatescript-tools txt /tmp/"${bases[0]}"
docker cp sstd:/tmp/"${bases[0]//.docx/.txt}" "${paths[0]//.docx/.txt}"
docker container rm sstd 1> /dev/null
;;
parens)
getfiles 1
docker run --rm -v "${paths[0]}":/tmp/"${bases[0]}" jonathanhuston/slatescript-tools parens /tmp/"${bases[0]}"
;;
checknums)
getfiles 2
docker run --rm -v "${paths[0]}":/tmp/"${bases[0]}" -v "${paths[1]}":/tmp/"${bases[1]}" jonathanhuston/slatescript-tools checknums /tmp/"${bases[0]}" /tmp/"${bases[1]}"
;;
*)
docker run --rm jonathanhuston/slatescript-tools help
;;
esac