From: Jonas Fonseca Date: Sat, 20 May 2006 02:45:22 +0000 (+0200) Subject: Make -h and --help options ouput a help message X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4b8c01a390e2118e6a1c8fc0c50a3be09787166f;p=tig.git Make -h and --help options ouput a help message --- diff --git a/tig.c b/tig.c index bf2d6ec..00791a7 100644 --- 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