Code

Make -h and --help options ouput a help message
authorJonas Fonseca <fonseca@diku.dk>
Sat, 20 May 2006 02:45:22 +0000 (04:45 +0200)
committerJonas Fonseca <fonseca@antimatter.localdomain>
Sat, 20 May 2006 02:55:40 +0000 (04:55 +0200)
tig.c

diff --git a/tig.c b/tig.c
index bf2d6ecdf62ad95a13f7696c93c06fc3d8820174..00791a7777fcf0c250b90960eb1171f3f970d899 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -208,6 +208,25 @@ sq_quote(char buf[SIZEOF_CMD], size_t bufsize, const char *src)
  * -------
  **/
 
+static const char usage[] =
+VERSION " (" __DATE__ ")\n"
+"\n"
+"Usage: tig [options]\n"
+"   or: tig [options] [--] [git log options]\n"
+"   or: tig [options] log  [git log options]\n"
+"   or: tig [options] diff [git diff options]\n"
+"   or: tig [options] show [git show options]\n"
+"   or: tig [options] <    [git command output]\n"
+"\n"
+"Options:\n"
+"  -l                          Start up in log view\n"
+"  -d                          Start up in diff view\n"
+"  -n[I], --line-number[=I]    Show line numbers with given interval\n"
+"  -t[N], --tab-size[=N]       Set number of spaces for tab expansion\n"
+"  --                          Mark end of tig options\n"
+"  -v, --version               Show version and exit\n"
+"  -h, --help                  Show help message and exit\n";
+
 /* Option and state variables. */
 static bool opt_line_number    = FALSE;
 static int opt_num_interval    = NUMBER_INTERVAL;
@@ -296,6 +315,16 @@ parse_options(int argc, char *argv[])
                        return FALSE;
                }
 
+               /**
+                * -h, --help::
+                *      Show help message and exit.
+                **/
+               if (!strcmp(opt, "-h") ||
+                   !strcmp(opt, "--help")) {
+                       printf(usage);
+                       return FALSE;
+               }
+
                /**
                 * \--::
                 *      End of tig(1) options. Useful when specifying command