]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Improving image help message
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Mon, 5 May 2025 14:19:51 +0000 (10:19 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Mon, 5 May 2025 14:19:51 +0000 (10:19 -0400)
app/emlrcvr.c
app/feeder.c
lib/unipar.c

index 6b5de8f06297be580d30c5b6707616ab7b44380c..caf0a743e3495ffade4a133985fa9bdf7705a2a0 100644 (file)
@@ -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;
index c4be65a89cb9e48939b5a26244a2e635fe41e2ff..d6f75cb202f8d8463e4d4acec3e11c0e86a48c4f 100644 (file)
@@ -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;
index f57bb53e1ba5cd2d068cb366dbfea7b2f3f52ef4..9d81e73b68d990b2f5f9174b25a59f6d37b7adcc 100644 (file)
@@ -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;
     }