From: Jean-Marc Pigeon (Delson) Date: Mon, 5 May 2025 14:19:51 +0000 (-0400) Subject: Improving image help message X-Git-Tag: tag-0.8~145 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=996f9d05e6c5e98454efdc676bd20127fc60de44;p=jmp%2Fmailleur Improving image help message --- diff --git a/app/emlrcvr.c b/app/emlrcvr.c index 6b5de8f..caf0a74 100644 --- a/app/emlrcvr.c +++ b/app/emlrcvr.c @@ -47,7 +47,7 @@ proceed=true; while (proceed==true) { switch (phase) { case 0 : //checking parameters - if ((params=par_getparams(argc,argv,"c:d:fh:r:v"))==(ARGTYP *)0) { + if ((params=par_getparams(argc,argv,"c:d:fhr:v"))==(ARGTYP *)0) { phase=999; //no need to go further } break; diff --git a/app/feeder.c b/app/feeder.c index c4be65a..d6f75cb 100644 --- a/app/feeder.c +++ b/app/feeder.c @@ -513,7 +513,7 @@ while (proceed==true) { //(void) fprintf(stdout,"JMPDBG main phase='%d'\n",phase); switch (phase) { case 0 : //checking parameters - if ((params=par_getparams(argc,argv,"c:d:fh:r:v"))==(ARGTYP *)0) { + if ((params=par_getparams(argc,argv,"c:d:fhr:v"))==(ARGTYP *)0) { proceed=false; //no need to go further } break; diff --git a/lib/unipar.c b/lib/unipar.c index f57bb53..9d81e73 100644 --- a/lib/unipar.c +++ b/lib/unipar.c @@ -42,25 +42,54 @@ return params; /* Display aid,aidhud usage parameter */ /* */ /********************************************************/ -static void usage_aid(char *name) +static void usage_aid(char *name,const char *select) { +static char *options[]={ + "c[-c config]", + "d[-d debug]", + "f[-f]", + "h[-h]", + "r[-r root]", + "v[-v]", + (char *)0 + }; + +static char *details[]={ + "-c config\t: set config file\n", + "-d level\t: debug level [1-10]\n", + "-f\t\t: start program in foreground (CLI) mode\n", + "-h\t\t: print this help message\n", + "-r root\t\t: root working directory\n", + "-v\t\t: Print program version number\n", + (char *)0 + }; + +int num; +char msg[200]; +char explain[1000]; + +num=0; +(void) sprintf(explain,"\twhere:\n"); (void) fprintf(stderr,"usage:\n "); -(void) fprintf(stderr,"%s\t" - "[-d debug] " - "[-c config] " - "[-f] " - "[-h] " - "[-r root] " - "[-v] " - "\n",name); -(void) fprintf(stderr,"\twhere:\n"); -(void) fprintf(stderr,"\t\t-d level\t: debug level [1-10]\n"); -(void) fprintf(stderr,"\t\t-c config\t: set config file\n"); -(void) fprintf(stderr,"\t\t-f\t\t: start program in foreground (CLI) mode\n"); -(void) fprintf(stderr,"\t\t-h\t\t: print this help message\n"); -(void) fprintf(stderr,"\t\t-r root\t\t: root working directory\n"); -(void) fprintf(stderr,"\t\t-v\t\t: Print program version number\n"); +(void) sprintf(msg,"%s\t",name); +while (options[num]!=(char *)0) { + char *ptr; + + ptr=options[num]; + if (strchr(select,*ptr)!=(char *)0) { + ptr++; + (void) strcat(msg," "); + (void) strcat(msg,ptr); + (void) strcat(explain,"\t\t"); + (void) strcat(explain,details[num]); + } + num++; + } +(void) fprintf(stderr,"%s\n",msg); +if ((select!=(char *)0)&&(strlen(select)>0)) { + (void) fprintf(stderr,"%s",explain); + } } /* ^L @@ -130,7 +159,7 @@ while (((c=getopt(argc,argv,optstring))!=EOF)&&(params!=(ARGTYP *)0)) { break; case 'h' : //requestion program help (void) fprintf(stderr,"%s-%s\n",shortname,rou_getversion()); - (void) usage_aid(shortname); + (void) usage_aid(shortname,optstring); params=par_freeparams(params); break; case 'r' : @@ -147,7 +176,7 @@ while (((c=getopt(argc,argv,optstring))!=EOF)&&(params!=(ARGTYP *)0)) { (void) fprintf(stderr,"%s-%s\n",shortname,rou_getversion()); (void) fprintf(stderr,"\"%s\" unexpected argument designator\n\n", argv[optind-1]); - (void) usage_aid(shortname); + (void) usage_aid(shortname,optstring); params=par_freeparams(params); break; }