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)
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);
181 strcpy(item,
" [--ui]");
182 len = show(fp, item, len);
190 fprintf(fp,
"{{{FLAGS}}}\n");
191 fprintf(fp,
"%s\n", _(
"Flags:"));
194 flag = &
st->first_flag;
195 while (flag !=
NULL) {
196 fprintf(fp,
" -%c ", flag->key);
199 fprintf(fp,
"%s\n", flag->label);
200 if (detailed && flag->description)
201 fprintf(fp,
" %s\n", flag->description);
204 else if (flag->description) {
205 fprintf(fp,
"%s\n", flag->description);
208 flag = flag->next_flag;
214 fprintf(fp,
" --o %s\n",
215 _(
"Allow output files to overwrite existing files"));
217 fprintf(fp,
" --h %s\n", _(
"Print usage summary"));
218 fprintf(fp,
" --v %s\n", _(
"Verbose module output"));
219 fprintf(fp,
" --q %s\n", _(
"Quiet module output"));
220 fprintf(fp,
" --qq %s\n", _(
"Super quiet module output"));
221 fprintf(fp,
" --ui %s\n", _(
"Force launching GUI dialog"));
229 fprintf(fp,
"{{{PARAMETERS}}}\n");
230 fprintf(fp,
"%s\n", _(
"Parameters:"));
231 opt = &
st->first_option;
232 while (opt !=
NULL) {
233 fprintf(fp,
" %*s ", maxlen, opt->key);
236 fprintf(fp,
"%s\n", opt->label);
237 if (detailed && opt->description) {
238 fprintf(fp,
" %*s %s\n",
239 maxlen,
" ", opt->description);
242 else if (opt->description) {
243 fprintf(fp,
"%s\n", opt->description);
247 show_options(fp, maxlen, opt->options);
253 fprintf(fp, _(
" %*s default: %s\n"), maxlen,
" ",
256 if (detailed && opt->descs) {
259 while (opt->opts[i]) {
261 fprintf(fp,
" %*s %s: %s\n",
262 maxlen,
" ", opt->opts[i], opt->descs[i]);
273 static void show_options(FILE *fp,
int maxlen,
const char *str)
279 fprintf(fp, _(
" %*s options: "), maxlen,
" ");
280 totlen = maxlen + 13;
282 while ((p2 = strchr(p1,
','))) {
284 len = strlen(p1) + 1;
285 if ((len + totlen) > 76) {
286 totlen = maxlen + 13;
287 fprintf(fp,
"\n %*s", maxlen + 13,
" ");
289 fprintf(fp,
"%s,", p1);
294 if ((len + totlen) > 76)
295 fprintf(fp,
"\n %*s", maxlen + 13,
" ");
296 fprintf(fp,
"%s\n", p1);
301 static int show(FILE *fp,
const char *item,
int len)
305 n = strlen(item) + (len > 0);
311 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.