Skip to content

Instantly share code, notes, and snippets.

@rkumar
Created December 6, 2011 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rkumar/1437194 to your computer and use it in GitHub Desktop.
Save rkumar/1437194 to your computer and use it in GitHub Desktop.
quick reporter from bugzy.sqlite database
# alias bs='b.sh'
# quickly report data from sqldatabase avoiding ruby's load time
# also colorize file
# colorize can only do a line, whereas sed allows us to do parts. but using ansi
# its not easy to do both lines and part, so it sucks
# most allows us to page horizontally
# less does not
# colorize only does basic colors, in bash we can do 256.
# NOTE :
# get colormap.sh at:
# https://gist.github.com/1437187
## change this to your path
cd /Users/rahul/work/projects/rbcurse/examples
file="t.sqlit"
out="t2.sqlit"
export END="\x1b[0m"
export ON_GRAY="\x1b[48;5;234m"
echo "${ON_GRAY} Bugs ${END}" > $out
echo " Bugs " > $out
echo ".mode column" > $file
echo "select id, title, priority, status,type from bugs where status = 'open' or status = 'started' order by priority , id;" >> $file
sqlite3 bugzy.sqlite < $file >> $out
STA='\\033[48;5;0m'
if [[ $BSSCHEME != "BLUE" ]]; then
P1='\\033[48;5;232m'
P2='\\033[48;5;233m'
P3='\\033[48;5;234m'
P4='\\033[48;5;235m'
P5='\\033[48;5;236m'
else
P1='\\033[48;5;16m'
P2='\\033[48;5;17m'
P3='\\033[48;5;18m'
P4='\\033[48;5;19m'
P5='\\033[48;5;20m'
fi
export ON_GRAY231='\\033[48;5;226m'
. ~/bin/colormap.sh
text=$(sed "\
s/\(.* started .*\)/${WHITE}${STA}\1${DEFAULT}/g;\
s/\(.* canceled .*\)/${BLACK}\1${DEFAULT}/g;\
s/\(.*P1.*\)/${YELLOW}${P1}\1${DEFAULT}/g;\
s/\(.*P2.*\)/${YELLOW}${P2}\1${DEFAULT}/g;\
s/\(.*P3.*\)/${CYAN}${P3}\1${DEFAULT}/g;\
s/\(.*P4.*\)/${GREEN}${P4}\1${DEFAULT}/g;\
s/\(.*P5.*\)/${BLUE}\1${DEFAULT}/g;\
s/enhancemen/ /g;\
s/feature/ /g;\
" $out)
echo "$text" | less
#s/P3/${LIGHT_CYAN}P3${DEFAULT}/g; \
#s/#fix/${LIGHT_RED}${ON_YELLOW}#fix${DEFAULT}/g; \
#s/#\([^ ]*\)/${BLACK}${ON_GREEN}#\1${DEFAULT}/g; \
#s/%\([^ ]*\)/${WHITE}${ON_BLUE}%\1${DEFAULT}/g; \
#s/clean/${UNDERLINE}clean${DEFAULT}/g; \
#most $out
rm $file $out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment