aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/tru/tinyradutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tru/tinyradutil.c')
-rw-r--r--src/tru/tinyradutil.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/tru/tinyradutil.c b/src/tru/tinyradutil.c
index e857282..9f4ab4f 100644
--- a/src/tru/tinyradutil.c
+++ b/src/tru/tinyradutil.c
@@ -109,31 +109,21 @@ const TinyRadUtilWidget tru_widget_map[] =
109{ 109{
110 { 110 {
111 .name = "configuration", 111 .name = "configuration",
112 .func = &tru_widget_config, 112 .desc = "print configuration",
113 .shortopts = TRU_COMMON_SHORT TRU_DICT_SHORT,
114 .longopts = (struct option []) { TRU_DICT_LONG TRU_COMMON_LONG },
115 .min_arg = 0,
116 .max_arg = 0,
117 .usage = NULL, 113 .usage = NULL,
118 .desc = "print configuration" 114 .aliases = NULL,
115 .func = &tru_widget_config
119 }, 116 },
120 { 117 {
121 .name = "dictionary", 118 .name = "dictionary",
122 .func = &tru_widget_dict, 119 .desc = "print processed dictionary",
123 .shortopts = TRU_COMMON_SHORT TRU_DICT_SHORT,
124 .longopts = (struct option []) { TRU_DICT_LONG TRU_COMMON_LONG },
125 .min_arg = 0,
126 .max_arg = 0,
127 .usage = NULL, 120 .usage = NULL,
128 .desc = "print processed dictionary" 121 .aliases = NULL,
122 .func = &tru_widget_dict
129 }, 123 },
130 { 124 {
131 .name = NULL, 125 .name = NULL,
132 .func = NULL, 126 .func = NULL,
133 .shortopts = NULL,
134 .longopts = NULL,
135 .min_arg = -1,
136 .max_arg = -1,
137 .usage = NULL, 127 .usage = NULL,
138 .desc = NULL 128 .desc = NULL
139 } 129 }
@@ -303,7 +293,7 @@ tru_cli_parse(
303 return(TRU_GETOPT_ERROR); 293 return(TRU_GETOPT_ERROR);
304 294
305 case 'h': 295 case 'h':
306 tru_usage(cnf); 296 tru_usage(cnf, short_opt);
307 return(TRU_GETOPT_EXIT); 297 return(TRU_GETOPT_EXIT);
308 298
309 case '?': 299 case '?':
@@ -384,12 +374,13 @@ tru_getopt(
384 374
385int 375int
386tru_usage( 376tru_usage(
387 TinyRadUtilConf * cnf ) 377 TinyRadUtilConf * cnf,
378 const char * short_opt )
388{ 379{
389 int i; 380 int i;
390 381
391 tru_usage_summary(cnf); 382 tru_usage_summary(cnf);
392 tru_usage_options(cnf); 383 tru_usage_options(short_opt);
393 if (!(cnf->widget)) 384 if (!(cnf->widget))
394 { 385 {
395 printf("WIDGETS:\n"); 386 printf("WIDGETS:\n");
@@ -404,13 +395,11 @@ tru_usage(
404 395
405void 396void
406tru_usage_options( 397tru_usage_options(
407 TinyRadUtilConf * cnf ) 398 const char * short_opt )
408{ 399{
409 const char * s; 400 const char * s;
410 401
411 s = TRU_COMMON_SHORT; 402 s = short_opt;
412 if ((cnf->widget))
413 s = ((cnf->widget->shortopts)) ? cnf->widget->shortopts : TRU_COMMON_SHORT;
414 403
415 printf("OPTIONS:\n"); 404 printf("OPTIONS:\n");
416 if ((strchr(s, 'b'))) printf(" -b, --builtin-dict load built-in dictionary\n"); 405 if ((strchr(s, 'b'))) printf(" -b, --builtin-dict load built-in dictionary\n");