Ticket #5347: apis.sh

File apis.sh, 453 bytes (added by mjethani, on 08/08/2017 at 10:58:17 AM)

A shell script to print out the names of the chrome.* APIs used by Adblock Plus

Line 
1#!/bin/bash -e
2
3# Print out the names of the chrome.* APIs used by Adblock Plus.
4
5# Output to terminal will be with color highlighting. If you're using a black
6# background, you can set GREP_COLOR to "1;32".
7
8apis="$@"
9files=$(hg status -A | sed -n 's/^C //p')
10
11if [ -z $apis ]; then
12  apis="$(grep -EwoIsh 'chrome(\.\w+)+' $files | sort -u)"
13fi
14
15for api in $apis; do
16  echo "# $api"; echo
17  grep -wIn -C5 --color=auto "${api//./\.}" $files
18  echo
19done