From: Antonio Ospite <ospite@studenti.unina.it>
Date: Sun, 26 May 2013 22:05:00 +0000 (+0200)
Subject: examples: print the usage message when a required option is missing
X-Git-Tag: v0.1.4~30
X-Git-Url: https://git.ao2.it/libam7xxx.git/commitdiff_plain/74c1a41d0765df9716732ac053df9ed7f24f38f0

examples: print the usage message when a required option is missing

While at it specify which option is missing when picoproj fails..
---

diff --git a/examples/am7xxx-play.c b/examples/am7xxx-play.c
index 38812a4..e958eee 100644
--- a/examples/am7xxx-play.c
+++ b/examples/am7xxx-play.c
@@ -777,7 +777,8 @@ int main(int argc, char *argv[])
 	}
 
 	if (input_path == NULL) {
-		fprintf(stderr, "The -i option must always be passed\n");
+		fprintf(stderr, "The -i option must always be passed\n\n");
+		usage(argv[0]);
 		ret = -EINVAL;
 		goto out;
 	}
diff --git a/examples/picoproj.c b/examples/picoproj.c
index 8341527..610e148 100644
--- a/examples/picoproj.c
+++ b/examples/picoproj.c
@@ -168,7 +168,8 @@ int main(int argc, char *argv[])
 	}
 
 	if (filename[0] == '\0') {
-		fprintf(stderr, "An image file MUST be specified.\n");
+		fprintf(stderr, "An image file MUST be specified with the -f option.\n\n");
+		usage(argv[0]);
 		exit_code = EXIT_FAILURE;
 		goto out;
 	}