#!/bin/sh
-if [ $# -ne 1 ]; then
- >&2 echo "Usage: $0 IDENTIFIER";
- exit 1;
-fi;
+grepc_usage()
+{
+ echo "Usage: $0 [OPTION] IDENTIFIER";
+}
+
+
+grepc_parse_cmd()
+{
+ while getopts "h" opt; do
+ case "$opt" in
+ h)
+ grepc_usage;
+ exit 0;
+ ;;
+ ?)
+ grepc_usage >&2;
+ exit 1;
+ ;;
+ esac;
+ done;
+ shift $(($OPTIND-1));
+
+ if [ $# -ne 1 ]; then
+ grepc_usage >&2;
+ exit 1;
+ fi;
+ identifier=$1;
+}
grepc_find_files()
main()
{
- grepc_find_files "$1";
+ grepc_parse_cmd $@;
+
+ grepc_find_files "$identifier";
- grepc_macro "$1";
- grepc_enum_constant "$1";
- grepc_func "$1";
- grepc_linux "$1";
- grepc_glibc "$1";
- grepc_type "$1";
+ grepc_macro "$identifier";
+ grepc_enum_constant "$identifier";
+ grepc_func "$identifier";
+ grepc_linux "$identifier";
+ grepc_glibc "$identifier";
+ grepc_type "$identifier";
}
-main "$1";
+main $@;
grepc \- find C declarations and definitions in source code
.SH SYNOPSIS
.B grepc
+.RI [ option ]
.I identifier
.SH DESCRIPTION
.MR grepc 1
is normally a C identifier,
but it is actually a PCRE pattern,
so it can be used to find complex patterns.
+.SH OPTIONS
+.TP
+.B \-h
+Output a help message and exit.
.SH EXAMPLES
.EX
.RB \(ti/src/nginx/unit$ " grepc nxt_sprintf;"