Make -h and --help options ouput a help message
[tig] / tig.c
diff --git a/tig.c b/tig.c
index 41105b9..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:
@@ -1388,7 +1417,7 @@ view_driver(struct view *view, enum request request)
                break;
 
        case REQ_SHOW_VERSION:
-               report("Version: %s", VERSION);
+               report("%s (built %s)", VERSION, __DATE__);
                return TRUE;
 
        case REQ_SCREEN_RESIZE:
@@ -1820,6 +1849,7 @@ static struct keymap keymap[] = {
         *      Move cursor one line down and enter.
         * PgUp::
         * b::
+        * -::
         *      Move cursor one page up.
         * PgDown::
         * Space::
@@ -1839,6 +1869,7 @@ static struct keymap keymap[] = {
        { ' ',          REQ_MOVE_PAGE_DOWN },
        { KEY_PPAGE,    REQ_MOVE_PAGE_UP },
        { 'b',          REQ_MOVE_PAGE_UP },
+       { '-',          REQ_MOVE_PAGE_UP },
 
        /**
         * Scrolling