From 66f9af1724c8af3ba44946ded419c5db54717aa5 Mon Sep 17 00:00:00 2001 From: Amir Zamani Date: Wed, 2 Mar 2016 14:36:13 +0330 Subject: [PATCH] add utils.sh for ctag generating and code line counting --- utils.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 utils.sh diff --git a/utils.sh b/utils.sh new file mode 100755 index 0000000..190c637 --- /dev/null +++ b/utils.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +CTAGS_EXCLUDES_BASE="--exclude=.git --exclude=tmp --exclude=xbin --exclude=res" +CTAGS_OPTIONS_BASE="--c++-kinds=+cefgnps --fields=+iaS --extra=+fq -R ." +CLOC_EXCLUDES_BASE="--exclude-dir=.git,xbin,tmp,res" +CLOC_EXCLUDES_LANGS="--exclude-lang=Prolog,make" + + +function fn_cloc() { +echo "cloc (exclusive) ..." +cloc $CLOC_EXCLUDES_LANGS $CLOC_EXCLUDES_BASE,3rdparty . +} + +function fn_cloc_all() { +echo "cloc all (inclusive) ..." +cloc $CLOC_EXCLUDES_LANGS $CLOC_EXCLUDES_BASE . +} + +function fn_ctags() { +echo "ctags (exclusive) ..." +ctags --exclude=3rdparty $CTAGS_EXCLUDES_BASE $CTAGS_OPTIONS_BASE +} + +function fn_ctags_all() { +echo "ctags all (inclusive) ..." +ctags $CTAGS_EXCLUDES_BASE $CTAGS_OPTIONS_BASE +} + +if [[ $# -eq 0 ]]; then + fn_ctags + +else + while [[ $# > 0 ]]; do + arg="$1" + + case $arg in + tags|ctags|tag|ctag) + fn_ctags + ;; + + tags_all|ctags_all|tag_all|fn_ctags_all) + fn_ctags_all + ;; + + cloc_all) + fn_cloc_all + ;; + + cloc) + fn_cloc + ;; + + *) + echo "unknown args as $arg" + ;; + + esac + shift + done +fi +