20#include <grass/glocale.h>
22#include "parser_local_proto.h"
24static void usage(FILE *fp,
int markers);
25static void show_options(FILE *fp,
int maxlen,
const char *str);
26static int show(FILE *fp,
const char *item,
int len);
58static void usage(FILE *fp,
int markers)
78 if (st->module_info.label || st->module_info.description) {
82 fprintf(fp,
"{{{DESCRIPTION}}}\n");
84 fprintf(fp,
"%s\n", _(
"Description:"));
85 if (st->module_info.label)
86 fprintf(fp,
" %s\n", st->module_info.label);
87 if (st->module_info.description)
88 fprintf(fp,
" %s\n", st->module_info.description);
93 if (st->module_info.label)
94 fprintf(fp,
"%s\n", st->module_info.label);
95 else if (st->module_info.description)
96 fprintf(fp,
"%s\n", st->module_info.description);
99 if (extensive && st->module_info.keywords) {
102 fprintf(fp,
"{{{KEYWORDS}}}\n");
103 fprintf(fp,
"%s\n ", _(
"Keywords:"));
110 fprintf(fp,
"{{{USAGE}}}\n");
111 fprintf(fp,
"%s\n ", _(
"Usage:"));
113 len = show(fp, st->pgm_name, 1);
121 flag = &st->first_flag;
122 for (n = 3; flag !=
NULL; n++, flag = flag->next_flag)
126 len = show(fp, item, len);
131 opt = &st->first_option;
132 while (opt !=
NULL) {
133 if (opt->key_desc !=
NULL)
134 key_desc = opt->key_desc;
135 else if (opt->type == TYPE_STRING)
141 fprintf(stderr,
"\n%s\n", _(
"ERROR: Option key not defined"));
144 n = strlen(opt->key);
151 strcat(item, opt->key);
153 strcat(item, key_desc);
156 strcat(item, key_desc);
157 strcat(item,
",...]");
162 len = show(fp, item, len);
168 strcpy(item,
" [--overwrite]");
169 len = show(fp, item, len);
172 strcpy(item,
" [--help]");
173 len = show(fp, item, len);
175 strcpy(item,
" [--verbose]");
176 len = show(fp, item, len);
178 strcpy(item,
" [--quiet]");
179 len = show(fp, item, len);
182 len = show(fp, item, len);
194 if (st->n_flags || standard) {
197 fprintf(fp,
"{{{FLAGS}}}\n");
198 fprintf(fp,
"%s\n", _(
"Flags:"));
202 flag = &st->first_flag;
203 while (flag !=
NULL) {
204 fprintf(fp,
" -%c ", flag->key);
207 fprintf(fp,
"%s\n", flag->label);
208 if (detailed && flag->description)
209 fprintf(fp,
" %s\n", flag->description);
211 else if (flag->description) {
212 fprintf(fp,
"%s\n", flag->description);
215 flag = flag->next_flag;
221 fprintf(fp,
" --o %s\n",
222 _(
"Allow output files to overwrite existing files"));
224 fprintf(fp,
" --h %s\n", _(
"Print usage summary"));
225 fprintf(fp,
" --v %s\n", _(
"Verbose module output"));
226 fprintf(fp,
" --q %s\n", _(
"Quiet module output"));
227 fprintf(fp,
" --qq %s\n", _(
"Super quiet module output"));
228 fprintf(fp,
" --ui %s\n", _(
"Force launching GUI dialog"));
236 fprintf(fp,
"{{{PARAMETERS}}}\n");
237 fprintf(fp,
"%s\n", _(
"Parameters:"));
238 opt = &st->first_option;
239 while (opt !=
NULL) {
240 fprintf(fp,
" %*s ", maxlen, opt->key);
243 fprintf(fp,
"%s\n", opt->label);
244 if (detailed && opt->description) {
245 fprintf(fp,
" %*s %s\n", maxlen,
" ", opt->description);
248 else if (opt->description) {
249 fprintf(fp,
"%s\n", opt->description);
253 show_options(fp, maxlen, opt->options);
259 fprintf(fp, _(
" %*s default: %s\n"), maxlen,
" ", opt->def);
261 if (detailed && opt->descs) {
264 while (opt->opts[i]) {
266 fprintf(fp,
" %*s %s: %s\n", maxlen,
" ",
267 opt->opts[i], opt->descs[i]);
278static void show_options(FILE *fp,
int maxlen,
const char *str)
284 fprintf(fp, _(
" %*s options: "), maxlen,
" ");
285 totlen = maxlen + 13;
287 while ((p2 = strchr(p1,
','))) {
289 len = strlen(p1) + 1;
290 if ((len + totlen) > 76) {
291 totlen = maxlen + 13;
292 fprintf(fp,
"\n %*s", maxlen + 13,
" ");
294 fprintf(fp,
"%s,", p1);
299 if ((len + totlen) > 76)
300 fprintf(fp,
"\n %*s", maxlen + 13,
" ");
301 fprintf(fp,
"%s\n", p1);
306static int show(FILE *fp,
const char *item,
int len)
310 n = strlen(item) + (len > 0);
316 fprintf(fp,
"%s", item);
void G_free(void *buf)
Free allocated memory.
void G__print_keywords(FILE *fd, void(*format)(FILE *, const char *), int newline)
Print list of keywords (internal use only)
int G__uses_new_gisprompt(void)
void G_usage(void)
Command line help/usage message.
const char * G_program_name(void)
Return module name.
char * G_store(const char *s)
Copy string to allocated memory.