diff --git a/slmenu.1 b/slmenu.1 index 797a8a7..89c443e 100644 --- a/slmenu.1 +++ b/slmenu.1 @@ -11,6 +11,7 @@ slmenu \- single line menu .RB [ \-p .IR prompt ] .RB [ \-v ] +.RB [ \-h ] .SH DESCRIPTION .B slmenu is a dynamic menu for the console, based on the wonderful @@ -40,6 +41,9 @@ defines the prompt to be displayed to the left of the input field. .TP .B \-v prints version information to stdout, then exits. +.TP +.B \-h +prints usage information to stdout, then exits. .SH USAGE slmenu is completely controlled by the keyboard. Besides standard Unix line editing and item selection (arrow keys, page up/down, home and end), the diff --git a/slmenu.c b/slmenu.c index e23a23d..466ba81 100644 --- a/slmenu.c +++ b/slmenu.c @@ -48,6 +48,7 @@ static void resetline(void); static void setup(void); static size_t textw(const char*); static size_t textwn(const char*, int); +static void usage(void); static char text[BUFSIZ] = ""; static int barpos = 0; @@ -632,6 +633,18 @@ size_t textwn(const char *s, int l) { return c+2; } +void usage(void) { + puts("usage: slmenu [-bhitv] [-l lines] [-p prompt]\n" + "\n" + " -b appear at the bottom of the terminal\n" + " -t appear at the top of the terminal\n" + " -i match menu items case insensitively\n" + " -l lines list items vertically, on the given number of lines\n" + " -p prompt display prompt to the left of the input field\n" + " -v print version information and exit\n" + " -h print this help and exit"); +} + int main(int argc, char **argv) { int i; @@ -642,6 +655,11 @@ int main(int argc, char **argv) { puts("slmenu, © 2011 slmenu engineers, see LICENSE for details"); exit(EXIT_SUCCESS); + } else if (!strcmp(argv[i], "-h")) { + /* help */ + usage(); + exit(EXIT_SUCCESS); + } else if (!strcmp(argv[i], "-i")) { /* case insensitive */ fstrncmp = strncasecmp;