comparison lwlib/lw_cmdline.c @ 192:8ae2670377ca

Added hidden options to lw_cmdline
author lost@l-w.ca
date Fri, 13 Jan 2012 21:33:55 -0700
parents ddffceb3c331
children d2bed389e94a
comparison
equal deleted inserted replaced
191:ddffceb3c331 192:8ae2670377ca
101 101
102 /* print short options that take no args */ 102 /* print short options that take no args */
103 t = 0; 103 t = 0;
104 for (i = 0; i < nopt + 3; i++) 104 for (i = 0; i < nopt + 3; i++)
105 { 105 {
106 if (slist[i]->flags & lw_cmdline_opt_hidden)
107 continue;
106 if (slist[i]->key > 0x20 && slist[i]->key < 0x7f) 108 if (slist[i]->key > 0x20 && slist[i]->key < 0x7f)
107 { 109 {
108 if (slist[i]->arg == NULL) 110 if (slist[i]->arg == NULL)
109 { 111 {
110 if (!t) 112 if (!t)
125 } 127 }
126 128
127 /* print short options that take args */ 129 /* print short options that take args */
128 for (i = 0; i < nopt + 3; i++) 130 for (i = 0; i < nopt + 3; i++)
129 { 131 {
132 if (slist[i]->flags & lw_cmdline_opt_hidden)
133 continue;
130 if (slist[i]->key > 0x20 && slist[i]->key < 0x7f && slist[i] -> arg) 134 if (slist[i]->key > 0x20 && slist[i]->key < 0x7f && slist[i] -> arg)
131 { 135 {
132 if (slist[i]->flags & lw_cmdline_opt_optional) 136 if (slist[i]->flags & lw_cmdline_opt_optional)
133 { 137 {
134 t = 7 + strlen(slist[i] -> arg); 138 t = 7 + strlen(slist[i] -> arg);
155 } 159 }
156 160
157 /* print long options */ 161 /* print long options */
158 for (i = 0; i < nopt + 3; i++) 162 for (i = 0; i < nopt + 3; i++)
159 { 163 {
164 if (slist[i]->flags & lw_cmdline_opt_hidden)
165 continue;
160 if (!(llist[i]->name)) 166 if (!(llist[i]->name))
161 continue; 167 continue;
162 if (llist[i]->arg) 168 if (llist[i]->arg)
163 { 169 {
164 t = strlen(llist[i] -> name) + 6 + strlen(llist[i] -> arg); 170 t = strlen(llist[i] -> name) + 6 + strlen(llist[i] -> arg);
262 fputc('\n', stdout); 268 fputc('\n', stdout);
263 269
264 /* display options - do it the naïve way for now */ 270 /* display options - do it the naïve way for now */
265 for (i = 0; i < (nopt + 3); i++) 271 for (i = 0; i < (nopt + 3); i++)
266 { 272 {
273 if (llist[i]->flags & lw_cmdline_opt_hidden)
274 continue;
267 noequ = 0; 275 noequ = 0;
268 if (llist[i] -> flags & lw_cmdline_opt_doc) 276 if (llist[i] -> flags & lw_cmdline_opt_doc)
269 { 277 {
270 col = strlen(llist[i] -> name) + 2; 278 col = strlen(llist[i] -> name) + 2;
271 printf(" %s", llist[i] -> name); 279 printf(" %s", llist[i] -> name);