From 8c5457305fa75c42147a113c81c7f8f0e8f8a7a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Sat, 30 May 2009 07:28:41 +0000 Subject: [PATCH] Add usage-text and print it if an option is not understood (or with -h) --- src/main.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 96e74d4a..7e8cb399 100644 --- a/src/main.c +++ b/src/main.c @@ -142,6 +142,32 @@ gtimer_disarm(gtimer_t *gti) } } +/** + * + */ +static void +usage(const char *argv0) +{ + printf("HTS Tvheadend %s\n", htsversion_full); + printf("usage: %s [options]\n", argv0); + printf("\n"); + printf(" -f Fork and daemonize\n"); + printf(" -u Run as user , only works with -f\n"); + printf(" -g Run as group , only works with -f\n"); + printf(" -C If no useraccount exist then create one with\n" + " no username and no password. Use with care as\n" + " it will allow world-wide administrative access\n" + " to your Tvheadend installation until you edit\n" + " the access-control from within the Tvheadend UI\n"); + printf("\n"); + printf("For more information read the man page or visit\n"); + printf(" http://www.lonelycoder.com/hts/\n"); + printf("\n"); + exit(0); + +} + + /** * @@ -196,7 +222,7 @@ main(int argc, char **argv) sigset_t set; const char *contentpath = TVHEADEND_CONTENT_PATH; - while((c = getopt(argc, argv, "fu:g:s:c:C")) != -1) { + while((c = getopt(argc, argv, "fu:g:c:Ch")) != -1) { switch(c) { case 'f': forkaway = 1; @@ -213,6 +239,8 @@ main(int argc, char **argv) case 'C': createdefault = 1; break; + default: + usage(argv[0]); } }