comparison sidinfo.c @ 75:92a4065c41d0

Improve listing of available fields in --help.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 01 Jan 2016 04:27:07 +0200
parents 2b2376f1b0cc
children 9fb70b7b34ff
comparison
equal deleted inserted replaced
74:5d61d8dbc77f 75:92a4065c41d0
123 static const int optListN = sizeof(optList) / sizeof(optList[0]); 123 static const int optListN = sizeof(optList) / sizeof(optList[0]);
124 124
125 125
126 void argShowHelp(void) 126 void argShowHelp(void)
127 { 127 {
128 int index, n; 128 int index, len;
129 129
130 th_print_banner(stdout, th_prog_name, "[options] <sid filename> [sid filename #2 ..]"); 130 th_print_banner(stdout, th_prog_name, "[options] <sid filename> [sid filename #2 ..]");
131 th_args_help(stdout, optList, optListN, 0); 131 th_args_help(stdout, optList, optListN, 0);
132 printf( 132 printf(
133 "\n" 133 "\n"
134 "Available fields:\n"); 134 "Available fields:\n");
135 135
136 for (index = n = 0; index < noptPSFlags; index++) 136 for (len = index = 0; index < noptPSFlags; index++)
137 { 137 {
138 const PSFOption *opt = &optPSFlags[index]; 138 const PSFOption *opt = &optPSFlags[index];
139 len += strlen(opt->name) + 3;
140 if (len >= 72)
141 {
142 printf("\n");
143 len = 0;
144 }
139 printf("%s%s", opt->name, (index < noptPSFlags - 1) ? ", " : "\n\n"); 145 printf("%s%s", opt->name, (index < noptPSFlags - 1) ? ", " : "\n\n");
140 if (++n > 5)
141 {
142 printf("\n");
143 n = 0;
144 }
145 } 146 }
146 147
147 printf( 148 printf(
148 "Example: %s -x -p -f hash,copyright somesidfile.sid\n" 149 "Example: %s -x -p -f hash,copyright somesidfile.sid\n"
149 "\n" 150 "\n"