From 5fd22c17e72e3ff49eb2050133958fe28750415c Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 11 May 2013 12:10:50 +0200 Subject: fb-helper: Add help output It is still meant to be only used as a backend for fb-client, but this makes testing easier. Signed-off-by: Florian Pritz --- fb-helper.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/fb-helper.c b/fb-helper.c index 760081a..5a429b2 100644 --- a/fb-helper.c +++ b/fb-helper.c @@ -213,6 +213,17 @@ int progress_callback( return 0; } +void display_help() +{ + printf("Usage: fb-helper \n"); + printf("\n"); + printf("Options:\n"); + printf(" -D Print debugging information\n"); + printf(" -h This help\n"); + printf(" -u URL of pastebin or URL to download\n"); + printf(" -f File to upload to URL\n"); +} + int main(int argc, char *argv[]) { CURL *curl = NULL; @@ -244,7 +255,12 @@ int main(int argc, char *argv[]) .url = NULL }; - while ((opt = getopt(argc, argv, "Du:f:m:")) != -1) { + if (argc == 1) { + display_help(); + exit(0); + } + + while ((opt = getopt(argc, argv, "Du:f:m:h")) != -1) { switch (opt) { case 'D': options.debug = 1; break; @@ -252,6 +268,11 @@ int main(int argc, char *argv[]) case 'f': options.file = optarg; break; + case 'h': + display_help(); + exit(0); + break; + default: fprintf(stderr, "Error: unknown option %c", opt); exit(1); -- cgit v1.2.3-24-g4f1b