Skip to content

Commit f7aa06b

Browse files
committed
Add resource slug input support for txpull
1 parent 835ae0d commit f7aa06b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

txpull

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
#!/bin/sh
22

3+
set -e
4+
35
if [ -z "$1" ]; then
46
echo "Usage: ./txpull <po file path> [<options or arguments for tx pull>]"
57
exit 1
68
fi
79

8-
if [ ! -f "$1" ]; then
9-
echo "File $1 does not exist"
10-
exit 1
10+
if [ -f "$1" ]; then
11+
file=$1
12+
elif [ -n "$(cat .tx/config | grep "\[python-36-tw\.$1\]")" ]; then
13+
file=$(cat .tx/config | grep -A 3 "\[python-36-tw\.$1]" | grep "trans.zh_TW = " | sed 's/trans\.zh_TW = //')
14+
else
15+
echo "Cannot find file or resource $1"
16+
exit 1
1117
fi
1218

13-
file="$1"
19+
resource_slug=$(cat .tx/config | grep -B 3 $file | grep "python-36-tw" | head -n 1 | sed 's/\[\(.*\)\]/\1/')
1420
shift
1521

16-
resource_slug="$(cat .tx/config | grep -B 3 $file | grep "python-36-tw" | head -n 1 | sed 's/\[\(.*\)\]/\1/')"
1722
if [ -z "$resource_slug" ]; then
18-
echo "Resource of file $file not found"
23+
echo "Cannot find resource slug of $file"
1924
exit 1
2025
fi
2126

0 commit comments

Comments
 (0)