19 #include <grass/gis.h> 20 #include <grass/glocale.h> 22 #include "parser_local_proto.h" 24 static void usage(FILE *fp,
int markers);
25 static void show_options(FILE *fp,
int maxlen,
const char *str);
26 static int show(FILE *fp,
const char *item,
int len);
58 static void usage(FILE *fp,
int markers)
75 if (
st->module_info.label ||
st->module_info.description) {
78 fprintf(fp,
"{{{DESCRIPTION}}}\n");
79 fprintf(fp,
"%s\n", _(
"Description:"));
80 if (
st->module_info.label)
81 fprintf(fp,
" %s\n",
st->module_info.label);
82 if (
st->module_info.description)
83 fprintf(fp,
" %s\n",
st->module_info.description);
85 if (
st->module_info.keywords) {
88 fprintf(fp,
"{{{KEYWORDS}}}\n");
89 fprintf(fp,
"%s\n ", _(
"Keywords:"));
96 fprintf(fp,
"{{{USAGE}}}\n");
97 fprintf(fp,
"%s\n ", _(
"Usage:"));
99 len = show(fp,
st->pgm_name, 1);
107 flag = &
st->first_flag;
108 for (n = 3; flag !=
NULL; n++, flag = flag->next_flag)
112 len = show(fp, item, len);
117 opt = &
st->first_option;
118 while (opt !=
NULL) {
119 if (opt->key_desc !=
NULL)
120 key_desc = opt->key_desc;
121 else if (opt->type == TYPE_STRING)
127 fprintf(stderr,
"\n%s\n", _(
"ERROR: Option key not defined"));
130 n = strlen(opt->key);
137 strcat(item, opt->key);
139 strcat(item, key_desc);
142 strcat(item, key_desc);
143 strcat(item,
",...]");
148 len = show(fp, item, len);
154 strcpy(item,
" [--overwrite]");
155 len = show(fp, item, len);
158 strcpy(item,
" [--help]");
159 len = show(fp, item, len);
161 strcpy(item,
" [--verbose]");
162 len = show(fp, item, len);
164 strcpy(item,
" [--quiet]");
165 len = show(fp, item, len);
167 strcpy(item,
" [--ui]");
168 len = show(fp, item, len);
176 fprintf(fp,
"{{{FLAGS}}}\n");
177 fprintf(fp,
"%s\n", _(
"Flags:"));
180 flag = &
st->first_flag;
181 while (flag !=
NULL) {
182 fprintf(fp,
" -%c ", flag->key);
185 fprintf(fp,
"%s\n", flag->label);
186 if (flag->description)
187 fprintf(fp,
" %s\n", flag->description);
190 else if (flag->description) {
191 fprintf(fp,
"%s\n", flag->description);
194 flag = flag->next_flag;
199 fprintf(fp,
" --o %s\n",
200 _(
"Allow output files to overwrite existing files"));
202 fprintf(fp,
" --h %s\n", _(
"Print usage summary"));
203 fprintf(fp,
" --v %s\n", _(
"Verbose module output"));
204 fprintf(fp,
" --q %s\n", _(
"Quiet module output"));
205 fprintf(fp,
" --ui %s\n", _(
"Force launching GUI dialog"));
212 fprintf(fp,
"{{{PARAMETERS}}}\n");
213 fprintf(fp,
"%s\n", _(
"Parameters:"));
214 opt = &
st->first_option;
215 while (opt !=
NULL) {
216 fprintf(fp,
" %*s ", maxlen, opt->key);
219 fprintf(fp,
"%s\n", opt->label);
220 if (opt->description) {
221 fprintf(fp,
" %*s %s\n",
222 maxlen,
" ", opt->description);
225 else if (opt->description) {
226 fprintf(fp,
"%s\n", opt->description);
230 show_options(fp, maxlen, opt->options);
236 fprintf(fp, _(
" %*s default: %s\n"), maxlen,
" ",
242 while (opt->opts[i]) {
244 fprintf(fp,
" %*s %s: %s\n",
245 maxlen,
" ", opt->opts[i], opt->descs[i]);
256 static void show_options(FILE *fp,
int maxlen,
const char *str)
262 fprintf(fp, _(
" %*s options: "), maxlen,
" ");
263 totlen = maxlen + 13;
265 while ((p2 = strchr(p1,
','))) {
267 len = strlen(p1) + 1;
268 if ((len + totlen) > 76) {
269 totlen = maxlen + 13;
270 fprintf(fp,
"\n %*s", maxlen + 13,
" ");
272 fprintf(fp,
"%s,", p1);
277 if ((len + totlen) > 76)
278 fprintf(fp,
"\n %*s", maxlen + 13,
" ");
279 fprintf(fp,
"%s\n", p1);
284 static int show(FILE *fp,
const char *item,
int len)
288 n = strlen(item) + (len > 0);
294 fprintf(fp,
"%s", item);
int G__uses_new_gisprompt(void)
char * G_store(const char *s)
Copy string to allocated memory.
const char * G_program_name(void)
Return module name.
void G_usage(void)
Command line help/usage message.
void G__print_keywords(FILE *fd, void(*format)(FILE *, const char *))
Print list of keywords (internal use only)
void G_free(void *buf)
Free allocated memory.