blob: 89ed33c0acc722c83a7d1e77816372f87980600e (
plain)
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
|
#! /bin/bash
# Default flags
clearlogcat=0;
if [ "$1" == "-c" ]; then
clearlogcat=1
shift
fi
if [ $# != 1 ]; then
echo "Syntax: adb.sh [-c] {E|W|I|D|V}
adb.sh outputs the logcat to standard output and filters out lines not related with this project.
\`dalvikvm\`, \`System.err\` and \`AndroidRuntime\` are included, as those are used to debug fatal crashes.
The only argument is the initial of your log priority. (Error/Warning/Info/Debug/Verbose)
You can optionally add the \`-c\` flag to clear the logcat prior to printing new logcat lines."
else
# These variables are just to higlight text:
color="\033[0;36m"
nocolor="\033[0m"
error="\033[0;31m"
# Retrieving current working path
oldpath="$(pwd)"
if [ $clearlogcat == 1 ]; then
echo -e "${color}Clearing${nocolor} last entries…"
adb logcat -c
fi
echo -e "${color}Searching${nocolor} for tags in source code…"
# cd project_root_folder
# This will traverse from current folder to its parent folderwork until it finds a .git folder:
cd "$(dirname "$0")"
while [ ! -d ".git" ]
do
cd ..
if [[ "$(pwd)" == "/" ]]; then
echo -e "${error}Aborting.${nocolor} Not inside a Git project."
exit 1
fi
done
tags=`grep -R 'TAG = ".*"' ime/app/src/main/java/com/* ime/jnidictionaryv1/src/main/java/com/* ime/jnidictionaryv2/src/main/java/com/*`
# We can go back to our original folder now:
cd "$oldpath"
tags="$(echo $tags | sed -E 's![a-z/A-Z12]*\.java: (protected |private )?(static )?(final )?String [A-Z_]* = "([^\"]*)";!\4!g')"
if [ -z $tags ]; then
echo -e "${error}Aborting.${nocolor} No tags found."
exit 2
fi
tags="$tags dalvikvm System.err AndroidRuntime "
comm="adb logcat $(echo "$tags" | sed "s/ /:$1 /g")*:S"
echo -e "${color}Running: $nocolor$comm"
# Run command:
echo -e "${color}Logcat:$nocolor"
$comm
fi
|