Better option parsing for the example program.
diff --git a/example.c b/example.c
index eb80d09..c4d12e7 100644
--- a/example.c
+++ b/example.c
@@ -13,10 +13,18 @@ void completion(const char *buf, linenoiseCompletions *lc) {
int main(int argc, char **argv) {
char *line;
+ char *prgname = argv[0];
- if (argc > 1 && !strcmp(argv[1],"--multiline")) {
- linenoiseSetMultiLine(1);
- printf("Using multi-line mode.\n");
+ while(argc > 1) {
+ argc--;
+ argv++;
+ if (!strcmp(*argv,"--multiline")) {
+ linenoiseSetMultiLine(1);
+ printf("Multi-line mode enabled.\n");
+ } else {
+ fprintf(stderr, "Usage: %s [--multiline]\n", prgname);
+ exit(1);
+ }
}
linenoiseSetCompletionCallback(completion);