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 bf2d6ec..00791a7 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;
@@ -297,6 +316,16 @@ parse_options(int argc, char *argv[])
                }
 
                /**
+                * -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
                 *      options for the main view. Example: