19 #include "parser_local_proto.h"
21 static void print_cli_flag(FILE *
file,
const char *key,
const char *label,
22 const char *description,
const char *indent);
23 static void print_cli_option(FILE *
file,
const struct Option *opt,
25 static void print_cli_example(FILE *
file,
const char *indent);
27 void print_cli_flag(FILE *
file,
const char *key,
const char *label,
28 const char *description,
const char *indent)
30 fprintf(
file,
"%s**", indent);
33 fprintf(
file,
"-%s**", key);
34 fprintf(
file, MD_NEWLINE);
37 fprintf(
file,
"%s", indent);
40 fprintf(
file, MD_NEWLINE);
43 if (description !=
NULL) {
44 fprintf(
file,
"%s", indent);
50 void print_cli_option(FILE *
file,
const struct Option *opt,
const char *indent)
71 fprintf(
file,
"%s**%s**=", indent, opt->
key);
72 fprintf(
file,
"*%s*", type);
75 fprintf(
file,
"*%s*,...]", type);
79 fprintf(
file,
" **[required]**");
81 fprintf(
file, MD_NEWLINE);
84 fprintf(
file,
"%s", indent);
90 fprintf(
file, MD_NEWLINE);
93 fprintf(
file,
"%s", indent);
99 fprintf(
file, MD_NEWLINE);
101 fprintf(
file,
"%s", indent);
103 fprintf(
file,
"%s: *",
_(
"Allowed values"));
109 fprintf(
file, MD_NEWLINE);
111 fprintf(
file,
"%s", indent);
113 fprintf(
file,
"%s:",
_(
"Default"));
124 while (opt->
opts[i]) {
126 fprintf(
file, MD_NEWLINE);
128 fprintf(
file,
"%s", indent);
129 char *thumbnails =
NULL;
131 if (strcmp(opt->
gisprompt,
"old,colortable,colortable") ==
133 thumbnails =
"colortables";
134 else if (strcmp(opt->
gisprompt,
"old,barscale,barscale") ==
136 thumbnails =
"barscales";
138 "old,northarrow,northarrow") == 0)
139 thumbnails =
"northarrows";
143 fprintf(
file,
" ", opt->
opts[i],
144 thumbnails, opt->
opts[i]);
153 fprintf(
file,
"**: ");
161 void print_cli_example(FILE *
file,
const char *indent)
163 fprintf(
file,
"\n%sExample:\n", indent);
165 fprintf(
file,
"\n%s```sh\n", indent);
166 fprintf(
file,
"%s%s", indent,
st->pgm_name);
168 const struct Option *first_required_rule_option =
174 opt = &
st->first_option;
176 while (opt !=
NULL) {
194 if (opt->
required || first_required_rule_option == opt) {
196 fprintf(
file,
"%s=", opt->
key);
221 fprintf(
file,
"%s", value);
228 fprintf(
file,
"0.0");
239 fprintf(
file,
"\n%s```\n", indent);
251 fprintf(
file,
"%s**%s**", indent,
st->pgm_name);
256 flag = &
st->first_flag;
257 fprintf(
file,
"%s[**-", indent);
258 while (flag !=
NULL) {
259 fprintf(
file,
"%c", flag->
key);
262 fprintf(
file,
"**]");
267 opt = &
st->first_option;
269 while (opt !=
NULL) {
287 fprintf(
file,
"%s", indent);
290 fprintf(
file,
"**%s**=", opt->
key);
291 fprintf(
file,
"*%s*", type);
293 fprintf(
file,
" [,");
294 fprintf(
file,
"*%s*,...]", type);
304 fprintf(
file,
"%s[**--overwrite**]\n", indent);
306 fprintf(
file,
"%s[**--verbose**]\n", indent);
307 fprintf(
file,
"%s[**--quiet**]\n", indent);
308 fprintf(
file,
"%s[**--qq**]\n", indent);
309 fprintf(
file,
"%s[**--ui**]\n", indent);
311 print_cli_example(
file, indent);
324 opt = &
st->first_option;
325 while (opt !=
NULL) {
326 print_cli_option(
file, opt, indent);
328 fprintf(
file, MD_NEWLINE);
334 if (
st->n_flags || new_prompt) {
335 flag = &
st->first_flag;
336 while (
st->n_flags && flag !=
NULL) {
339 fprintf(
file, MD_NEWLINE);
344 print_cli_flag(
file,
"overwrite",
NULL,
345 _(
"Allow output files to overwrite existing files"),
347 fprintf(
file, MD_NEWLINE);
352 print_cli_flag(
file,
"help",
NULL,
_(
"Print usage summary"), indent);
353 fprintf(
file, MD_NEWLINE);
355 print_cli_flag(
file,
"verbose",
NULL,
_(
"Verbose module output"), indent);
356 fprintf(
file, MD_NEWLINE);
358 print_cli_flag(
file,
"quiet",
NULL,
_(
"Quiet module output"), indent);
359 fprintf(
file, MD_NEWLINE);
361 print_cli_flag(
file,
"qq",
NULL,
_(
"Very quiet module output"), indent);
362 fprintf(
file, MD_NEWLINE);
364 print_cli_flag(
file,
"ui",
NULL,
_(
"Force launching GUI dialog"), indent);
void G_free(void *)
Free allocated memory.
void G_free_tokens(char **)
Free memory allocated to tokens.
char * G_chop(char *)
Chop leading and trailing white spaces.
char * G_store(const char *)
Copy string to allocated memory.
char ** G_tokenize(const char *, const char *)
Tokenize string.
int G__uses_new_gisprompt(void)
const struct Option * G__first_required_option_from_rules(void)
void G__md_print_cli_long_version(FILE *file, const char *indent)
void G__md_print_cli_short_version(FILE *file, const char *indent)
void G__md_print_escaped(FILE *f, const char *str)
void G__md_print_escaped_for_options(FILE *f, const char *str)
Structure that stores flag info.
Structure that stores option information.