[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [clazy] /: add a --help option. remove '.md' extension from --list and --explain
From:       Allen Winter <allen.winter () kdab ! com>
Date:       2016-06-14 19:49:35
Message-ID: E1bCuL9-0002oW-8x () scm ! kde ! org
[Download RAW message or body]

Git commit 1b1bc9e3f676c97e06385e3e55bf88fab2898b6f by Allen Winter.
Committed on 14/06/2016 at 19:49.
Pushed by winterz into branch 'master'.

add a --help option.  remove '.md' extension from --list and --explain

M  +36   -14   clazy.cmake

http://commits.kde.org/clazy/1b1bc9e3f676c97e06385e3e55bf88fab2898b6f

diff --git a/clazy.cmake b/clazy.cmake
index 33a8bb9..e81ecac 100644
--- a/clazy.cmake
+++ b/clazy.cmake
@@ -1,30 +1,52 @@
 #!/usr/bin/env sh
 
-#TODO help command line option
-#TODO version command line option
-
 libdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@
 sharedir=@CMAKE_INSTALL_PREFIX@/@SHARE_INSTALL_DIR@/clazy
 
+HELP() {
+  echo "Usage: `basename $0` [options] [clang++-options]"
+  echo
+  echo "Static analyzer for C++/Qt code"
+  echo
+  echo "Options:"
+  echo "  --help             print program help"
+  echo "  --list             print a list of all available checkers, arranged by \
level" +  echo "  --explain [regexp] print explanations for the checker matching a \
regexp" +  echo "or"
+  echo "  --explain          print explanations for all checkers"
+  echo
+  echo "Any of the options above will print the requested information and then \
exit." +  echo "Otherwise, options are passed directly to clang++ and handled from \
there." +  echo
+  echo "See the clang++ manual for a list of the very large set of options \
available" +  echo
+}
+
 PRLIST() {
   echo ""
   echo "Checks from level$1. $2:"
-  ls -1 $sharedir/doc/level$1/README* | awk -F/ '{printf("    %s\n", $NF)}' | sed \
s/README-// | sort +  ls -1 $sharedir/doc/level$1/README* | awk -F/ '{printf("    \
%s\n", $NF)}' | sed s/README-// | sed s/\.md$// | sort  }
 
 PRINFO() {
-    lst=`ls -1 $sharedir/doc/level*/README*$1*`
-    for f in $lst
-    do
-        l=`echo $f | awk -F/ '{foo=NF-1; printf("    %s:%s\n", $foo,$NF)}'`
-        level=`echo $l | cut -d: -f1`
-        checker=`echo $l | cut -d: -f2 | sed s/README-//`
-        echo "== Explanation for checker $checker ($level) =="
-        cat $f
-        echo
-    done
+  lst=`ls -1 $sharedir/doc/level*/README*$1*`
+  for f in $lst
+  do
+    l=`echo $f | awk -F/ '{foo=NF-1; printf("    %s:%s\n", $foo,$NF)}'`
+    level=`echo $l | cut -d: -f1`
+    checker=`echo $l | cut -d: -f2 | sed s/README-// | sed s/\.md$//`
+    echo "== Explanation for checker $checker ($level) =="
+    cat $f
+    echo
+  done
 }
 
+if ( test $# -gt 0 -a "$1" = "--help" )
+then
+  HELP
+  exit
+fi
+
 if ( test $# -gt 0 -a "$1" = "--list" )
 then
   echo "List of available clazy checkers:"


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic