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);
207 fprintf(
file,
"\n%s```\n", indent);
219 fprintf(
file,
"%s**%s**", indent,
st->pgm_name);
224 flag = &
st->first_flag;
225 fprintf(
file,
"%s[**-", indent);
226 while (flag !=
NULL) {
227 fprintf(
file,
"%c", flag->
key);
230 fprintf(
file,
"**]");
235 opt = &
st->first_option;
237 while (opt !=
NULL) {
255 fprintf(
file,
"%s", indent);
258 fprintf(
file,
"**%s**=", opt->
key);
259 fprintf(
file,
"*%s*", type);
261 fprintf(
file,
" [,");
262 fprintf(
file,
"*%s*,...]", type);
272 fprintf(
file,
"%s[**--overwrite**]\n", indent);
274 fprintf(
file,
"%s[**--verbose**]\n", indent);
275 fprintf(
file,
"%s[**--quiet**]\n", indent);
276 fprintf(
file,
"%s[**--qq**]\n", indent);
277 fprintf(
file,
"%s[**--ui**]\n", indent);
279 print_cli_example(
file, indent);
292 opt = &
st->first_option;
293 while (opt !=
NULL) {
294 print_cli_option(
file, opt, indent);
296 fprintf(
file, MD_NEWLINE);
302 if (
st->n_flags || new_prompt) {
303 flag = &
st->first_flag;
304 while (
st->n_flags && flag !=
NULL) {
307 fprintf(
file, MD_NEWLINE);
312 print_cli_flag(
file,
"overwrite",
NULL,
313 _(
"Allow output files to overwrite existing files"),
315 fprintf(
file, MD_NEWLINE);
320 print_cli_flag(
file,
"help",
NULL,
_(
"Print usage summary"), indent);
321 fprintf(
file, MD_NEWLINE);
323 print_cli_flag(
file,
"verbose",
NULL,
_(
"Verbose module output"), indent);
324 fprintf(
file, MD_NEWLINE);
326 print_cli_flag(
file,
"quiet",
NULL,
_(
"Quiet module output"), indent);
327 fprintf(
file, MD_NEWLINE);
329 print_cli_flag(
file,
"qq",
NULL,
_(
"Very quiet module output"), indent);
330 fprintf(
file, MD_NEWLINE);
332 print_cli_flag(
file,
"ui",
NULL,
_(
"Force launching GUI dialog"), indent);
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.