From e3e4ca1d68a194bea9ac48f8a670bff1c84f79fc Mon Sep 17 00:00:00 2001 From: Joseph Poirier Date: Tue, 16 Jun 2015 22:49:54 -0500 Subject: [PATCH] add help option --- picoc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/picoc.c b/picoc.c index d3386c2..b272777 100644 --- a/picoc.c +++ b/picoc.c @@ -23,13 +23,14 @@ int main(int argc, char **argv) int StackSize = getenv("STACKSIZE") ? atoi(getenv("STACKSIZE")) : PICOC_STACK_SIZE; Picoc pc; - if (argc < 2) { + if (argc < 2 || strcmp(argv[ParamCount], "-h") == 0) { printf(PICOC_VERSION " \n" - "Format: picoc ... [- ...] : run a program (calls main() to start it)\n" - " picoc -s ... [- ...] : script mode - runs the program without calling main()\n" - " picoc -i : interactive mode (Ctrl+D to exit)\n" - " picoc -c : print the copyright info to stdout\n"); - exit(1); + "Format: picoc ... [- ...] : run a program, calls main() as the entry point\n" + " picoc -s ... [- ...] : run a script, runs the program without calling main()\n" + " picoc -i : interactive mode, Ctrl+d to exit\n" + " picoc -c : copyright info\n" + " picoc -h : this help message\n"); + return 0; } if (strcmp(argv[ParamCount], "-c") == 0) {